Skip to main content
PJano.1
Associate II
May 1, 2023
Solved

Why is ADC + DMA not triggered?

  • May 1, 2023
  • 5 replies
  • 3939 views

Hi! I'm using STM32 F301C8T for my LLC converter project. I have two MOSFETs switching at variable frequencies ranging from 80kHz to 400 kHz. Due to significant noise caused by switching, I need to time the output voltage measurement between the switches of MOSFETs.

I use TIM2 for PWM to switch the MOSFETs and TIM1 to count output events of TIM2 (TIM2's arr = 4, meaning that every 5TIM2 overflows, TIM1 overflows as well). Using the debugger, I checked that TIM1 counts appropriately.

I set ADC conversion to be triggered by "Timer 1 Trigger Out Event," and it seems like the AD conversion is not triggered. (+using DMA in circular mode).

Can you guys please advise what I am doing wrong?
_legacyfs_online_stmicro_images_0693W00000bj8zZQAQ.png
_legacyfs_online_stmicro_images_0693W00000bj8zeQAA.png
_legacyfs_online_stmicro_images_0693W00000bj8zyQAA.pngI start the TIMs and ADC by:

HAL_TIM_Base_Start_IT(&htim1);

HAL_ADC_Start_DMA(&hadc1,(uint32_t*) adcResultsDMA,4);

HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);

HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3);

Thank you! Pj

This topic has been closed for replies.
Best answer by PJano.1

Hi Amel, thanks, but this didn't solve the issue. I, however, managed to find a solution- my ADC setup in CubeMX was wrong. It should be as follows:


_legacyfs_online_stmicro_images_0693W00000bjTZmQAM.png

5 replies

LCE
Principal II
May 2, 2023

in main, is dma init function called before timer and adc init? If not, place it before these inits.

PJano.1
PJano.1Author
Associate II
May 2, 2023

Yes, it is. Main.txt attached.

Amel NASRI
ST Technical Moderator
May 5, 2023

Hi @PJano.1​ ,

Before "HAL_ADC_Start_DMA", it is required to calibrate the ADC:

HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);

Please let me know if this resolves your issue.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
PJano.1
PJano.1AuthorBest answer
Associate II
May 5, 2023

Hi Amel, thanks, but this didn't solve the issue. I, however, managed to find a solution- my ADC setup in CubeMX was wrong. It should be as follows:


_legacyfs_online_stmicro_images_0693W00000bjTZmQAM.png

Amel NASRI
ST Technical Moderator
May 5, 2023

Glad to know that you found the solution. Thanks for sharing it.

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.