2020-08-31 12:19 PM
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 ?
Solved! Go to Solution.
2020-08-31 12:43 PM
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.
2020-08-31 12:23 PM
Missing imagery..
Depends if the ADC read is pulling the left or right aligned register.
2020-08-31 12:31 PM
I left alignment thing as default as I have always been
I will try to mess with that
2020-08-31 12:43 PM
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.
2020-08-31 12:55 PM
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.
2020-08-31 12:57 PM
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);