2026-02-16 5:33 AM
Hi,
I am using Nucleo-L476RG. My I want to send data over SPI every 20000ms and during this 20000ms MCU will goes in sleep/standby mode. I want to keep track time of last 2 SPI data transmission.
But the issue is HAL_GetTick() reset after waking up from standby mode. so not able to track the time between last two data transfer.
2026-02-16 5:35 AM
Use the RTC ?
2026-02-16 5:37 AM
In sleep mode, data is kept. Should be straightforward doing this.
In standby mode, SRAM data is lost but you can adjust your program to keep SRAM2 and store data there between resets. You'll have to ensure it is not initialized on startup.
2026-02-16 6:14 AM - edited 2026-02-16 6:16 AM
I want to keep track exact time between last 2 data transfer like.
1 data sent at 1ms --> MCU goes sleep/ standby mode for 20000ms --> MCU wake Up --> 2nd data sent at 20001ms --> MCU goes sleep/ standby mode for 20000ms --> MCU wake Up --> 3rd data sent at 20004ms --> MCU goes sleep/ standby mode for 20000ms --> MCU wake Up....
The issue is HAL_GetTick() reset after waking up from standby mode. so not able to track the time between last two data transfer.
I can't use RTC because it is not battery powered device.
Is there any solution for the same?
2026-02-16 6:23 AM
@mangesh1 wrote:I can't use RTC because it is not battery powered device.
Sure, you can use the RTC in a non battery-powered device!
2026-02-17 12:33 AM
Hello @mangesh1
If using STOP mode is an available option, you can use LPTIMER to track the time between each 2 data transfers.
BR
Gyessine
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.