Update RTC when uploading the program?

Hello community,

I’m currently facing an issue with updating RTC variables on my Nextion display when uploading code. Here’s the scenario:

When I use the debug function in the Nextion editor, the time appears to work correctly, but upon uploading the code to my display, the time is inaccurate. I’ve incorporated a backup battery in the display, and the time is updated through a timer that triggers every second.

The relevant code snippet for updating the time is as follows:

p19.pic = rtc3 + 326;
p20.pic = rtc4 + 350;

the constants after the rtc are “zero” pictures.

I suspect that there might be a discrepancy in how the code behaves during debug and after uploading. Has anyone experienced a similar issue, and if so, how did you resolve it? Could it be related to the backup battery or some nuances in the upload process?

I appreciate any insights or suggestions to help me troubleshoot and resolve this RTC variable update issue. Thank you!