cancel
Showing results for 
Search instead for 
Did you mean: 

ADC + DMA over TIM trigger = Weird Values ???

hashtala
Associate II

So I fired up CUBE

started ADC over DMA with circular mode and Half Word to memory

then I added Continuous DMA requests and set TIM5 as trigger source

I then set up timer

ADC is 12 bits

then I started everything and this happened

however I do not understand why I have these big values when max value should be 4096???

any ideas ?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Looks like your array has 32-bit elements. You're viewing 2 values at once, with one of them in the upper half-word and the other in the lower half-word.

86115591 doesn't fit into 16 bits.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5

Missing imagery..

Depends if the ADC read is pulling the left or right aligned register.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hashtala
Associate II

0693W000002lw72QAA.png

I left alignment thing as default as I have always been

I will try to mess with that

TDK
Guru

Looks like your array has 32-bit elements. You're viewing 2 values at once, with one of them in the upper half-word and the other in the lower half-word.

86115591 doesn't fit into 16 bits.

If you feel a post has answered your question, please click "Accept as Solution".

well that's actually what is must be.

since adc has 12 bits I though I would store them into uint16 but HAL complained since HAL_ADC_START_DMA actually expects 32 bits unsigned integer

so am I getting 1024 values instead of 512 ? but since sampling rate should not be affected by that if I just split these values I should be good to go right /

However I do not want to waste DSP time converting this full word values into half words.

what would be the most efficient solution ?

thanks again, you're hero.

TDK
Guru

Define your array as uint16_t and cast the pointer as needed.

uint16_t array[1024];
 
...
 
HAL_ADC_Start_DMA(&hadc, (uint32_t *) array, 1024);

If you feel a post has answered your question, please click "Accept as Solution".