cancel
Showing results for 
Search instead for 
Did you mean: 

What is the value of LPTIM_CNT after MCU RESET?

Takahashi
Associate II

Hello ST microelectronics support team.

I'm developing an IOT application using the STM32WLE5CC for gas measurement. To measure the pulses I'm thinking of using the LPTIM, but I have a doubt.

In topic 26.4.14 of the RM0461 reference manual, I became aware of two ways to reset the counter, synchronous and asynchronous mode. My question is what happens to the value of the counter, when the MCU undergoes a reset, for example a reset caused by the Watchdog.

I understand that after undergoing a reset, the LPTIM will be unconfigured, but in case there is no interruption in the power supply to the MCU, would it be possible that after restarting, the LPTIM will be able to continue counting from the previous value?

Best Regards.

3 REPLIES 3

This is typically not how things work.

Perhaps you can maintain counts in the RTC/BKP unit? Has 20x 32-bit registers

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Bob S
Principal

If the watchdog triggers, something is broken in your firmware or hardware and you should count on throwing away any in-progress measurements as they would be unreliable. Likewise an external reset.

That said, while I don't have experience with the STM32WLE55, the L4xx the reference manual clearly states that the reset value of the LPTIM CNT register is zero. Look at the LPTIM_CNT register description in the ref man for your CPU and see what it says (very likely the same thing). If so, then, no, the timer cannot keep counting from the value it had before the reset.

Now if the reset is due to the WWDG, you have the possibility of using the "early wakeup" interrupt to save the current LPTIM_CNT value and then restore it after reset. But the resulting timer period will not account for the time between that interrupt and the actual reset, nor the time spent rebooting the CPU before your code restarts the LPTIM.

Hello Bob and Tesla.

I was a little hasty in posting this question, after taking a closer look at the project's architecture. I verified that the equipment must be powered by a battery. The equipment should sleep most of the time, waking up once every hour, where the LPTIM count will be read, accumulate the count and send this data through the Lora network. While the processor is sleeping, I think it makes no sense to worry about resetting the watchdog.

Thanks a lot for the replies.