phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2375
Posted: 11:05pm 21 Jan 2025
From DS1307 datasheet. So with no battery and Flag% stored there that should ensure the flag is only erased on power fail and not Reset.
n%=54321 > SAVE PERSISTENT n% Error : Expected a string > SAVE PERSISTENT "n%" Error : Expected a string > ? mm.info(PERSISTENT) Error : Syntax > > option list PicoMiteVGA MMBasic RP2350A Edition V6.00.02b1
Another option if the Flag doesn't get updated too often.
RTC GetTime
If Val(Right$(Date$,4)) > 2024 Then VAR RESTORE Else Flag% = 0 EndIf
RTC SetTime ....2025
'..... If InfrequentCondition Then VAR SAVE Flag% EndIf
Edited 2025-01-22 10:18 by phil99
Footnote added 2025-01-22 21:59 by phil99 Late entry Beta2 has now been released with SAVE PERSISTENT added and as noted by @btwolf a few posts below this, some form of error test may be needed. He suggests a checksum. If that is 8 bits you still have 56 to play with. Though if the number saved is always less than say 32 bits a simple IF MM.INFO(PERSISTENT) < 2^32 Then ... or whatever will do.
SAVE PERSISTENT 54321 > ? MM.INFO(PERSISTENT) 54321 > cpu restart > ? MM.INFO(PERSISTENT) 54321 PicoMiteVGA MMBasic RP2350A Edition V6.00.02b2 'reset button Copyright 2011-2024 Geoff Graham Copyright 2016-2024 Peter Mather
> ? MM.INFO(PERSISTENT) 8695604412579392460 'random data after reset PicoMiteVGA MMBasic RP2350A Edition V6.00.02b2 'reset button Copyright 2011-2024 Geoff Graham Copyright 2016-2024 Peter Mather