Mercurial > public > hwos_code
annotate src/rtc.asm @ 598:e1f0f5e3d4e4
BUGFIX: Internal deco planner did not display results in imperial units
author | heinrichsweikamp |
---|---|
date | Mon, 30 Jul 2018 19:45:53 +0200 |
parents | b455b31ce022 |
children | ca4556fb60b9 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
582 | 3 ; File rtc.asm ## V2.98 |
0 | 4 ; |
5 ; | |
6 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
7 ;============================================================================= | |
8 ; HISTORY | |
9 ; 2011-08-08 : [mH] moving from OSTC code | |
10 | |
275 | 11 #include "hwos.inc" |
0 | 12 #include "math.inc" |
13 | |
582 | 14 sensors CODE |
15 | |
16 ;============================================================================= | |
0 | 17 |
18 global rtc_init | |
19 rtc_init: | |
20 movlw .1 | |
21 movwf secs | |
22 movlw .59 | |
23 movwf mins | |
24 movlw .12 | |
25 movwf hours | |
582 | 26 movlw .1 |
0 | 27 movwf day |
598
e1f0f5e3d4e4
BUGFIX: Internal deco planner did not display results in imperial units
heinrichsweikamp
parents:
582
diff
changeset
|
28 movlw .8 |
0 | 29 movwf month |
582 | 30 movlw .18 |
0 | 31 movwf year |
463 | 32 ; rcall rtc_set_rtc ; writes mins,sec,hours,day,month and year to rtc module |
33 ; return | |
582 | 34 |
0 | 35 global rtc_set_rtc |
36 rtc_set_rtc: | |
582 | 37 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM |
38 movlw 0x55 | |
39 movwf EECON2 | |
40 movlw 0xAA | |
41 movwf EECON2 | |
42 bsf RTCCFG,RTCWREN ; Unlock sequence for RTCWREN | |
43 bsf RTCCFG,RTCPTR1 | |
44 bsf RTCCFG,RTCPTR0 ; year | |
0 | 45 movff year,WREG |
582 | 46 rcall rtc_dec2bcd ; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h! |
0 | 47 movwf RTCVALL ; year |
48 movwf RTCVALH ; dummy write | |
49 movff day,WREG | |
582 | 50 rcall rtc_dec2bcd ; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h! |
51 movwf RTCVALL ; day | |
0 | 52 movff month,WREG |
582 | 53 rcall rtc_dec2bcd ; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h! |
54 movwf RTCVALH ; month | |
0 | 55 movff hours,WREG |
582 | 56 rcall rtc_dec2bcd ; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h! |
57 movwf RTCVALL ; hours | |
0 | 58 movlw d'0' |
582 | 59 rcall rtc_dec2bcd ; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h! |
60 movwf RTCVALH ; weekday | |
0 | 61 movff secs,WREG |
582 | 62 rcall rtc_dec2bcd ; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h! |
63 movwf RTCVALL ; secs | |
0 | 64 movff mins,WREG |
582 | 65 rcall rtc_dec2bcd ; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h! |
66 movwf RTCVALH ; minutes | |
67 movlw 0x55 | |
68 movwf EECON2 | |
69 movlw 0xAA | |
70 movwf EECON2 | |
71 bcf RTCCFG,RTCWREN ; Lock sequence for RTCWREN | |
0 | 72 banksel common |
73 return | |
74 | |
75 rtc_dec2bcd: | |
582 | 76 banksel lo |
77 movwf lo ; Input in decimal | |
78 setf hi ; 10s | |
0 | 79 rtc_dec2bcd2: |
582 | 80 incf hi,F ; Count 10's |
0 | 81 movlw d'10' |
582 | 82 subwf lo,F |
0 | 83 btfss STATUS,N |
84 bra rtc_dec2bcd2 | |
85 movlw d'10' | |
582 | 86 addwf lo,F ; 1s |
87 swapf hi,W ; swap to bit 7-4 -> WREG | |
88 addwf lo,W ; Result in BCD | |
89 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM | |
0 | 90 return |
91 | |
92 END |