2019-12-26 06:17 AM
Hello ST team,
my platform: STM32f429
I use ADC with DMA in double buffer mode.
The ADC_ConvCallback is only called when the Memory0 is filled. There is no Callback called when the memory1 is filled.
This due to the hdma->XferM1CpltCallback which is NULL.
I can't use HAL_DMA_RegisterCallback(hdma, HAL_DMA_XFER_M1CPLT_CB_ID, ADC_DMAConvCplt) as ADC_DMAConvCplt() is static
It could be fine to initialize both callback in HAL_ADC_Start_DMA()
/* Set the DMA transfer complete callback */
hadc->DMA_Handle->XferCpltCallback = ADC_DMAConvCplt;
hadc->DMA_Handle->XferM1CpltCallback = ADC_DMAConvCplt;
/* Set the DMA half transfer complete callback */
hadc->DMA_Handle->XferHalfCpltCallback = ADC_DMAHalfConvCplt;
hadc->DMA_Handle->XferM1HalfCpltCallback = ADC_DMAHalfConvCplt;
Best regards
2019-12-26 09:53 AM
Learnt the hard way that users of the HAL should read the file header explanations before using the non intuitive functions.
I understood that when a peripheral is used along with a DMA, only the peripheral HAL DMA functions should be the focus.
The DMA HAL functions shouldn't be used by user.
2019-12-26 01:06 PM
Easiest thing to do is write your own isr and don't rely on the hal callbacks.
All you need to do is check the current bank (buffer) bit in the dma statis reg in your isr and read from the other. As far as i can tell, this works the same as using 1/2 and full buffer interrupts with a 2x sized buffer, the only difference being that in double buffer mode the buffers don't need to be contiguous.