Skip to main content
hashtala
Associate III
August 31, 2020
Solved

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

  • August 31, 2020
  • 5 replies
  • 1638 views

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 ?

This topic has been closed for replies.
Best answer by TDK

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.

5 replies

Tesla DeLorean
Guru
August 31, 2020

Missing imagery..

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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
hashtala
hashtalaAuthor
Associate III
August 31, 2020

0693W000002lw72QAA.png

I left alignment thing as default as I have always been

I will try to mess with that

TDK
TDKBest answer
August 31, 2020

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""."
hashtala
hashtalaAuthor
Associate III
August 31, 2020

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
August 31, 2020

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""."