cancel
Showing results for 
Search instead for 
Did you mean: 

Why is ADC + DMA not triggered?

PJano.1
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5
LCE
Principal

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

PJano.1
Associate II

Yes, it is. Main.txt attached.

Amel NASRI
ST Employee

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 Accept as Solution on the reply which solved your issue or answered your question.

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

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.