2019-03-29 05:47 AM
Hello there,
I was wondering either it is possible (with STM32L4) to turn on a PWM channel for a certain amount of cycles or for a certain amount of time? Ideally, without any interrupts during this period or at the end.
I am trying to figure out a way to re-trigger an external watchdog supervisor without breaking the MCU from sleep mode. For example, lets say the wdg device has to be retriggered every 500 ms and I would like to sleep the MCU for 2 seconds. With this functionality, I would configure the peripheral to do 4 cycles (assuming 500 ms period) or to work for 2 secs (any period less than 500 ms is ok).
Turning the pwm peripheral without any timeout could cause a deadlock in the application.
In case this is not possible, I thought of using an external multivibrator, that would make the additional line toggle for me while I am asleep... But its a bit too much.
I would appreciate all help.
Solved! Go to Solution.
2019-03-29 06:10 AM
Check low power timer, otherwise for a burst of pulses I would think to use advanced timer repetition counter, or use timer output compare fed by dma from a table of compare values, detecting the dma tranfer complete being the event.
2019-03-29 06:00 AM
MCU sleep means clock stop mode?
2019-03-29 06:04 AM
I believe not. The other timer (TIM3) I am using for 3 channels PWM generation without the global interrupt turned on is working all the time.
2019-03-29 06:10 AM
Check low power timer, otherwise for a burst of pulses I would think to use advanced timer repetition counter, or use timer output compare fed by dma from a table of compare values, detecting the dma tranfer complete being the event.
2019-03-29 06:11 AM
This seems reasonable, will check it out. Thanks.
2019-03-29 06:18 AM
Let us know later which solution you used and what made you choose. Thanks.
2019-03-29 06:46 AM
Its seems like LPTIM1/2 One-pulse mode is exactly what I need (If I understood the functionality correctly). If I set LSI as clock source (32k) and set the prescaler to 32, it would give me 1 ms time base. So in order to make a 1500 ms pulse I would do:
HAL_LPTIM_OnePulse_Start(lptim_handle, 1500, 0);
I dont have the scope with me, so will be able to test it later only. Thanks for the hint.
2019-03-30 04:12 AM
Hi,
I have checked the LPTIM functionality with scope. It works as its supposed to. Bellow an 850 ms pulse is being generated with:
HAL_LPTIM_OnePulse_Start(lptim_handle, 850, 0);
32k LSI as LPTIM1 source with /32 divider.