You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a low-frequency system clock (such as 1M), CNT may exceed CMP in LPTIM_IRQHandler, so that the lptimer interrupt cannot be generated normally. #22
I use a Cortex-M4 processor with a 1Mhz main frequency, and lptimer uses an external 32.768khz crystal oscillator.
Assume that when the lptimer interrupt request occurs, the interrupt in the program is disabled or there is a higher priority interrupt to be processed. So when the LPTIM_IRQHandler function is called back for execution, there is already a delay.
At the beginning of the LPTIM_IRQHandler function, the cnt value of the lptimer at the current moment is obtained to obtain ulCountsLate and compare it with ulTimerCountsForOneTick.
If ulCountsLate <ulTimerCountsForOneTick at this moment (but ulCountsLate still has 4 or 5 counts that will satisfy ulCountsLate >=ulTimerCountsForOneTick), the code will execute the statement block that satisfies ulCountsLate <ulTimerCountsForOneTick, that is, the value of the CMP register will be changed, but this modification will not take effect immediately (it is implied to take effect when the LPTIM_ISR_CMPOK interrupt is generated).
When obtaining the cnt value and cmp modification successfully, due to the low system main frequency, this delay will be very long (in my example it takes a total of 198us), so that when the modification is successful, the CNT value may have exceeded the CMP value, so that the lptimer interrupt cannot be generated normally, so that the tickless processing code related to cnt and cmp is entered again, and an error occurs.