cancel
Showing results for 
Search instead for 
Did you mean: 

STMF0 HAL ADC DMA buffer 16bit vs. 32bit

JuM
Senior
Posted on July 06, 2018 at 08:01

If I declare the ADC-DMA dest buffer as

   static uint32_t adc32_dma [5];

and call

   HAL_ADC_Start_DMA (&hadc, adc32_dma, 5);

I get wrong results in dest buffer.

If I declare the ADC-DMA dest buffer as

   static uint16_t adc16_dma [5];

and call

  HAL_ADC_Start_DMA (&hadc, (uint32_t *)adc16_dma, 5);

I get correct results in dest buffer.

Two questions:

   - Why we have to define a 16bit buffer but pass it as (uint32_t *) to HAL?

   - Why this is undocumented in Description of STM32F0 HAL and low-layer drivers?

Took me half a day to finally find it in an example...

Juergen
1 REPLY 1
JuM
Senior
Posted on July 06, 2018 at 10:58

Solved:

One has to configure DMA in CubeMX for WORD transfer (default is HALFWORD==16bit), then can use 32 bit ADC-DMA-dest buffers: