2022-05-20 12:07 PM
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.
2022-05-20 12:44 PM
This is typically not how things work.
Perhaps you can maintain counts in the RTC/BKP unit? Has 20x 32-bit registers
2022-05-20 12:44 PM
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.
2022-05-20 01:02 PM
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.