Hi guys, I am implementing the low power mode function.
The aim is to enter VLPS mode, and wake up the MCU from VLPS by LPTMR every 80ms.
After wake up, enable LPIT with period 600us to trigger AD function.
Now, the issue is the period of LPIT is not correct.
The designed period is 600us, but the measured period is 4ms or so.
The incorrect period is just happened at the first cycle after waked up from VLPS. The afterward period is quit correct.
Some other information:
LPTMR: clock source is SIRC.
LPIT: clock source is SIRC.
Could anyone help me ? Thanks in advance.
How do you enable and disable the LPIT timer?
You can reset the module first (MCR[SW_RST]).
Please have a look at the Table 48-4. Initializing the LPIT module in the RM.
Thanks for response.
At current implementation, as LPIT doesn't work at VLPS mode, so I do nothing to LPIT when waked up from VLPS mode. I assumed LPIT module would continue working after waked up.
Also, I tried starting the LPIT channel whenever waked up from VLPS mode. We use MCAL code, so the interface I used is Gpt_StartChannel(channel, period). But the result was the same.
So in your opinion, we need reset the LPIT module when MCU waked up from VLPS mode?
I tested it with a simple bare-metal code and couldn't reproduce it.
The LPIT module starts immediately - it does not have to be restarted.
I routed LPIT Ch0 trigger to a TRGMUX_OUT pin and output BUS_CLK at a CLKOUT pin.
After a wake-up:
The first period is shorter 0.4752ms.
But this is because the LPIT period was interrupt by the VLPS after 0.1384ms.
Can you test it with TRGMUX and CLKOUT on your side?
I guess you use LPIT interrupts and it takes some time to enable the LPIT interrupt after a wake-up event.
Thanks very much for your detailed response.
I tested and tried other methods. Finally, I found out the root cause.
It's the Clock! Before enter LPM, PLL and FIRC are disabled.
When waked up by interrupt, interrupt handler is executed first and then MCU exit from VLPS.
In my code, I start LPIT in the interrupt handler. At this point, the system clock is still SIRC. So this causes the incorrect period.
One solution is to change clock to PLL in the interrupt handler and then start LPIT.
Thanks again for you suggestion.