trigger ADC every "X" IRQs from TIM
Hi, I'm building an LLC converter using STM32F301C8. The converter consists of MOSFET half-bridge. The output voltage is controlled by changing the switching frequency with a constant duty cycle of 50%. I use TIM2 for PWM and adjust the frequency using macros (40kHz - 400 kHz switching). Center-aligned mode 1 in CUBE IDE.
I use ADC to measure the output voltage and PI controller for control. When switching the MOSFETs, there is a lot of noise. Therefore I would like to trigger the ADC measurement between the switching when no noise is created by switching MOSFETs.
The issue is when I use TIM2 update interrupt, the MCU gets overloaded and stops responding due to too many IRQs (400 kHz worst case) - which makes sense.
*Is there a way to trigger the ADC once per every, let's say ten TIM2 updates, please?
I tried having a second timer with a ten times higher ARR value than TIM2 to trigger the IRQ, but that seemed unreliable due to frequent frequency adjustments (when changing frequency for TIM2 and TIM1 I had to use a different line of code causing a shift between the TIMs).
Thank you!
PJ.
