2023-05-01 11:39 AM - edited 2023-11-20 06:43 AM
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?
I 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
Solved! Go to Solution.
2023-05-05 05:27 AM - edited 2023-11-20 06:44 AM
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:
2023-05-01 10:01 PM
in main, is dma init function called before timer and adc init? If not, place it before these inits.
2023-05-01 11:36 PM
2023-05-05 04:04 AM
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.
2023-05-05 05:27 AM - edited 2023-11-20 06:44 AM
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:
2023-05-05 06:02 AM
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.