cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 ADC DMA, where are results of measurements

rafal2399
Associate
Posted on December 28, 2012 at 09:21

Board STM32F0 Discovery, measurment on 4 analog inputs:

PC0 - ADC_IN10

PC1 - ADC_IN11

PC2 - ADC_IN12

PC3 - ADC_IN13

and Vbat, Vref, Vtemp.

Configuration of ADC1 and DMA is shown in attachment.

for ''ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Upward''

content of table looks like below:

ADC_DATA[0]=2034

ADC_DATA[1]=2273 - PC0

ADC_DATA[2]=2069 - PC1

ADC_DATA[3]=2000 - PC2

ADC_DATA[4]=2225 - PC3

ADC_DATA[5]=1950

ADC_DATA[6]=1695

for: ''ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Backward''

content of table looks like below:

ADC_DATA[0]=2135 - PC0

ADC_DATA[1]=2051

ADC_DATA[2]=1702

ADC_DATA[3]=1945

ADC_DATA[4]=2251 - PC3

ADC_DATA[5]=2078 - PC2

ADC_DATA[6]=2071 - PC1

results of measurements are transmitted via uart every 1 second (pure ascii string).

place of result of measurement of PC0, PC1, PC2 and PC3 i'm sure because it is zero when i shorted to gnd

Which index of array contains measurements of channel 16, 17 and 18 (Vbat, Vref and Vtemp)?

Why data are mixed?

In manual, on page 201, bit SCANDIR decides of direction of scanning, from CHSEL0 to CHSEL16 or opposite direction. What about chanels 17(Vref) and 18(Vbat)?

Where i'm doing wrong?

#adc-dma-stm32f0-stm32f0discovery
3 REPLIES 3
raptorhal2
Lead
Posted on December 28, 2012 at 17:11

Page 201 of the reference manual defines external channels in bits 0 to 15 and VTemp and VRef in bits bits 16 and 17. I presume VBat is bit 18.

The internal channels are in the ADC_Data arrays in the correct sequence. Notice that the scanning up values  in [5], [6] and [0] match the scanning backwards values in [3], [2] and [1] after allowing for conversion noise. The external channels have similar noise.

The mismatch between array position and first value to be converted is puzzling. Check the array length variable and the indexing logic in the 1 sec UART code.

Cheers, Hal

raptorhal2
Lead
Posted on December 29, 2012 at 01:54

Cancel post

Martin Davey
Associate III
Posted on January 02, 2013 at 17:54

One thing I have just noticed in an application I am working on:

ADC_GetCalibrationFactor(ADCx);

is causing a DMA transfer. This meant all my array was out of alignemt by by 1 position. Although my code is derived from ST example, I have not explicitly checked ST example stand-alone.

Martin.