AnsweredAssumed Answered

ADC to memory through DMA - data order

Question asked by rybak.tomasz on Jan 4, 2013
Latest reply on Jan 11, 2013 by rybak.tomasz
Hi!
I am using STM32F0DISCOVERY kit and so far tried to run one of the peripheral examples called ADC_DMA. Short example description: "The ADC1 is configured to convert continuously Voltage reference and Temperature sensor. Each time an end of conversion occurs the DMA transfers, in circular mode, the converted data from ADC1 DR register to the RegularConvData_Tab[] table."
The temperature sensor is connected to channel ADC_IN16 and the internal voltage reference VREFINT is connected to channel ADC1_IN17.
The order in which the channels are scanned is configured as follows:

    ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Backward;

so (as I read from the documentation) the channels are scanned from Channel 18 to Channel 0, which means that VREFINT is converted first, and then temperature. This, in my opinion, should result in the first converted data (VREFINT) going to RegularConvData_Tab[0], and the second converted data (temperature) to RegularConvData_Tab[1]. However, the example code is written like this (note the indexes [0] and [1]):

    /* Convert temperature sensor voltage value in mv */
    TempSensVoltmv = (uint32_t)((RegularConvData_Tab[0]* 3300) / 0xFFF);
    
    /* Convert Vref voltage value in mv */
    VrefIntVoltmv  = (uint32_t)((RegularConvData_Tab[1]* 3300) / 0xFFF);

In fact, after running the program on board, I can see the temperature in RegularConvData_Tab[0] and VREFINT in RegularConvData_Tab[1].
Where's the mistake in my thinking?

By the way: since the board has a VDD=VDDA=3V, I guess in the above equations there should be "*3000" instead of "*3300"? I checked measuring voltage on some analog input (channel ADC_IN1) and multiplying by 3000 gave me pretty similar value to what the multimeter showed.

Regards,
Tomek

Outcomes