This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F3 analog-digital converter

Hello.
I am using a STM32F303 development board and i am trying to use the 4 ADCs that incorporates.My first question is it's possible to use the 4 ADCs in the same time?. I want to measure four voltages variating from 0 to 3.6v on one analog input of each ADC.If anyone has an idea about how to do, i will be very grateful.
Best Regards

Parents
  • Hey,

    may be the problem is more in the value´s calculating part than in the init of the adc.
    I assume you have a Vref = 3,3V(?).
    You may have an overrun issue in your equation
    (ADC1ConvertedValue *3300)/0xFFF.

    with an inputvoltage = 1.5V the ADC1ConvertedValue would be
    1.) (1.5/3.3) * ((2^12)-1) = 1861
    2.) 1861 * 3300 = 6141300

    I don´t know enough about what the compiler is doing with the (1861 * 3300) operation. If it is performed on the ADC1ConvertedValue variable and the result is stored there you´d have an overrun problem. I don´t know if the compiler handles that by it´s own.
    So in first run try to change the ADC1ConvertedValue variable to an uint32_t and cast it back to uint16_t AFTER dividing it by 4096.

Reply
  • Hey,

    may be the problem is more in the value´s calculating part than in the init of the adc.
    I assume you have a Vref = 3,3V(?).
    You may have an overrun issue in your equation
    (ADC1ConvertedValue *3300)/0xFFF.

    with an inputvoltage = 1.5V the ADC1ConvertedValue would be
    1.) (1.5/3.3) * ((2^12)-1) = 1861
    2.) 1861 * 3300 = 6141300

    I don´t know enough about what the compiler is doing with the (1861 * 3300) operation. If it is performed on the ADC1ConvertedValue variable and the result is stored there you´d have an overrun problem. I don´t know if the compiler handles that by it´s own.
    So in first run try to change the ADC1ConvertedValue variable to an uint32_t and cast it back to uint16_t AFTER dividing it by 4096.

Children
  • Hey,

    For the Vref, i don't know its value. In STM32F302xx/STM32F303xx electrical characteristics, i have noticed that Vref is connected to Vdda, so i measured with millimeter its value on stm32f3-discovery and found 3V. Then, i changed this line(ADC1ConvertedValue *3300)/0xFFF by (ADC1ConvertedValue *3000)/0xFFF. So the problem was resolved.

    I don't know if my way to proceed is correct or no...

    Otherwise, i don't understand your point 1) and 2).

  • I have a question about the ADC clock of STM32F3. In fact in the examlples given by ST configure this clock like this:

    RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div1); //that's mean that the ADC is derived from the PLL Clock (72Mhz in this case). In the same time ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;
    So based on the data sheet, with this configuration has the advantage to reach the maximum of the ADC clock but it's not synchronized with the AHB clock. if i want to use timer to trigger the conversion of ADC, we have to use the AHB clock to drive the ADC clock.

    For that purpose i have configured my ADC clock like this :

    /* Configures the AHB clock (HCLK) ***/

    RCC_HCLKConfig(RCC_SYSCLK_Div1); // RCC_AHB_Clock_Source( 72MHz in this case ). Then :
    ADC_CommonInitStructure.ADC_Clock = ADC_Clock_SynClkModeDiv4; // this gives us 18 MHz

    Do you thank this configuration is correct or no ? Thank in advance of your help.