Skip to main content
Visitor II
November 22, 2024
Question

STM32 ADC and DMA with LL libraries

  • November 22, 2024
  • 0 replies
  • 1104 views

Hello everyone, I'm trying to sample some signals inside a timer ISR. I use all three ADC units of the mC (multiple channels in the first unit and 1 channel in each of the other two units) and I use software triggering and DMA transfer.This operation works well with HAL libraries, by only using the command HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length).
Now I need to make the transition to LL libraries, because the HAL_ADC_Start_DMA function takes too much execution time due to its complexity.
I am doing the basic configuration through CubeMX and then I interfere in the auto-generated code. What I am doing with LL is (among others) to add some lines into the auto-generated code so that to configure the addresses (LL_DMA_ConfigAddresses) and enable the DMA stream needed, in the initialization stage.
So when the timer ISR starts (50kHz frequency), I enable the ADCs in the very first cycle (and wait for stabilization) and then in every cycle I trigger the conversion start with LL_ADC_REG_StartConversionSWStart command.
Finally, after this trigger, I clear in every cycle the OVR and EOC flags (the EOC flag raises for every single channel) and then I execute the other commands in the routine (mathematical processing of the values etc).

However, it seems that the routine isn't working as expected and I cannot read the samples correctly. What I'm observing is that I either read only in the very first cycle or I read for some cycles and then the values do not update.
Does anyone have a similar issue and also an idea on how to deal with it (e.g. with a working example code)?

Thank you in advance!

    This topic has been closed for replies.