RTC functions from Graph 35+E II OS 3.10 <80054456 RTC_GetRawTime> Gets the time into a structure of the following form, where all objects are written in BCD notation. struct RTC_RawTime { uint16_t YEAR; uint8_t MONTH; uint8_t DAY; uint8_t HOURS; uint8_t MINUTES; uint8_t SECONDS; uint8_t zero; }; /* 8 bytes */ r4: Pointer to [struct RTC_RawTime] 80054456: d510 mov.l 0xa413fec2 RTC.RSECCNT, r5 80054458: e1f8 mov #-8, r1 8005445a: 8556 mov.w @(12,r5), r0 8005445c: 620d extu.w r0, r2 8005445e: 421c shad r1, r2 80054460: 2420 mov.b r2, @r4 80054462: 8041 mov.b r0, @(1,r4) 80054464: 845a mov.b @(10,r5), r0 80054466: 8042 mov.b r0, @(2,r4) 80054468: 8458 mov.b @(8,r5), r0 8005446a: 8043 mov.b r0, @(3,r4) 8005446c: 8454 mov.b @(4,r5), r0 8005446e: 8044 mov.b r0, @(4,r4) 80054470: 8452 mov.b @(2,r5), r0 80054472: 8045 mov.b r0, @(5,r4) 80054474: 6050 mov.b @r5, r0 80054476: 8046 mov.b r0, @(6,r4) 80054478: e000 mov #0, r0 8005447a: 000b rts 8005447c: 8047 mov.b r0, @(7,r4) ... <8005788c RTC_IsInitialized> Checks whether the RTC is initialized by comparing the current date with the (probably default) date of 2019-01-01. (Note: this OS 3.10 was compiled in 2019 so this choice makes sense, even if the default has long been 2012.) r0: 1 if the RTC is initialized, 0 otherwise. # Get current time in BCD format 8005788c: 4f22 sts.l pr, @-r15 8005788e: 7ff8 add #-8, r15 80057890: d271 mov.l 0x80054456 RTC_GetRawTime, r2 80057892: 420b jsr @r2 80057894: 64f3 mov r15, r4 # Return 1 if the current date is not 2019-01-01 80057896: 60f0 mov.b @r15, r0 80057898: 8820 cmp/eq #32, r0 8005789a: 8b09 bf <800578b0> 8005789c: 84f1 mov.b @(1,r15), r0 8005789e: 8819 cmp/eq #25, r0 800578a0: 8b06 bf <800578b0> 800578a2: 84f2 mov.b @(2,r15), r0 800578a4: 8801 cmp/eq #1, r0 800578a6: 8b03 bf <800578b0> 800578a8: 84f3 mov.b @(3,r15), r0 800578aa: 8801 cmp/eq #1, r0 # Return 0 otherwise 800578ac: 8d01 bt.s <800578b2> 800578ae: e000 mov #0, r0 800578b0: e001 mov #1, r0 800578b2: 7f08 add #8, r15 800578b4: 4f26 lds.l @r15+, pr 800578b6: 000b rts 800578b8: 0009 nop <800578ba RTC_TimeCategorySinceReset> Returns a broad categorization of the time spent since last RTC reset. The category is computed by comparing the current time to the default time of RTC_IsInitialized (2019-01-01). The categories are defined by the following ranges of time spent since last RTC reset: 3: More than 12 hours 2: Between 15 minutes and 12 hours 1: Between 10 minutes and 15 minutes 0: Less than 10 minutes # Get tick-based time, divide by 128 to get second-based time and round to 0 # (adding 127 to a negative tick-time rounds near 0, but is useless here). 800578ba: 2fe6 mov.l r14, @-r15 800578bc: 4f22 sts.l pr, @-r15 800578be: d267 mov.l %03b RTC_GetTicks, r2 800578c0: 420b jsr @r2 800578c2: 0009 nop 800578c4: 4011 cmp/pz r0 800578c6: 8d01 bt.s <800578cc> 800578c8: 6e03 mov r0, r14 800578ca: 7e7f add #127, r14 800578cc: e2f9 mov #-7, r2 # Return: # -> 3 if current date is after 2019-01-01 12:00 # -> 2 if it's before that but still after 00:15 # -> 1 if it's before that but still after 00:10 # -> 0 if it's before 00:10 800578ce: bfdd bsr <8005788c RTC_IsInitialized> 800578d0: 4e2c shad r2, r14 800578d2: 8801 cmp/eq #1, r0 800578d4: 890a bt <800578ec> 800578d6: d262 mov.l 0x0000a8c0, r2 800578d8: 3e23 cmp/ge r2, r14 800578da: 8907 bt <800578ec> 800578dc: 9293 mov.w 0x00000384, r2 800578de: 3e23 cmp/ge r2, r14 800578e0: 8d05 bt.s <800578ee> 800578e2: e002 mov #2, r0 800578e4: 9290 mov.w 0x00000258, r2 800578e6: 3e23 cmp/ge r2, r14 800578e8: a001 bra <800578ee> 800578ea: 0029 movt r0 800578ec: e003 mov #3, r0 800578ee: 4f26 lds.l @r15+, pr 800578f0: 000b rts 800578f2: 6ef6 mov.l @r15+, r14