annotate code_part1/OSTC_code_asm_part1/adc_rtc.asm @ 53:263348f83485

1.70 cleaning the code
author heinrichsweikamp
date Sat, 31 Jul 2010 10:25:59 +0200
parents 73014f788032
children 31fa973a70fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1 ; OSTC - diving computer code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
4 ; This program is free software: you can redistribute it and/or modify
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
5 ; it under the terms of the GNU General Public License as published by
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
6 ; the Free Software Foundation, either version 3 of the License, or
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
7 ; (at your option) any later version.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
9 ; This program is distributed in the hope that it will be useful,
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
12 ; GNU General Public License for more details.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
13
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
14 ; You should have received a copy of the GNU General Public License
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
17
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
18 ; routines for AD converter, Realtime clock initialisation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
20 ; written: 10/30/05
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
21 ; last updated: 05/15/08
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
22 ; known bugs:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
23 ; ToDo:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
24
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
25 get_battery_voltage: ; starts ADC and waits until fnished
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
26 bsf ADCON0,0 ; power on ADC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
27 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
28 bsf ADCON0,1 ; start ADC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
29 get_battery_voltage2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
30 btfsc ADCON0,1 ; Wait...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
31 bra get_battery_voltage2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
32
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
33 ; 3.3V/1024=3,2227mV Input/Bit=9,6680mV Battery/Bit.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
34 ; Example: 434*9,6680mV=4195,9mV Battery.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
35
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
36 movff ADRESH,xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
37 movff ADRESL,xA+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
38 movlw LOW d'966'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
39 movwf xB+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
40 movlw HIGH d'966'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
41 movwf xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
42 call mult16x16 ; AD_Result*966
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
43 movlw d'100'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
44 movwf xB+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
45 clrf xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
46 call div32x16 ;xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
47 movff xC+0,batt_voltage+0 ; store value
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
48 movff xC+1,batt_voltage+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
49 bcf ADCON0,0 ; power off ADC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
50
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 ; Check if we should enter deep-sleep mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
52
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 movff batt_voltage+0,sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54 movff batt_voltage+1,sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
55 movlw LOW d'2600' ; must be greater then 2600mV...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
56 movwf sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
57 movlw HIGH d'2600'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
58 movwf sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
59 call sub16 ; sub_c = sub_a - sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
60 bcf enter_error_sleep ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61 btfsc neg_flag ; neg_flag=1 if eeprom40:41 < 2000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 bra get_battery_voltage3 ; Battery in OK range
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 movlw d'2'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65 movwf fatal_error_code ; Battery very low!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 bsf enter_error_sleep ; enter error routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68 get_battery_voltage3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
69 movff amb_pressure+0,sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70 movff amb_pressure+1,sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 movlw LOW d'15001' ; must be lower then 15001mBar
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72 movwf sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73 movlw HIGH d'15001'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
74 movwf sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
75 call sub16 ; sub_c = sub_a - sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76 bcf enter_error_sleep ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
77 btfss neg_flag ;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
78 bra get_battery_voltage4 ; Pressure in OK range
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
80 movlw d'3'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
81 movwf fatal_error_code ; too deep
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
82 bsf enter_error_sleep ; enter error routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
83 ; Continue with rest of routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
84
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
85 get_battery_voltage4:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
86 ; check if the battery control memory needs to be initialised!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
87 bcf initialize_battery1 ; clear check-flags
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
88 bcf initialize_battery2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
89
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90 read_int_eeprom d'40' ; get lowest battery voltage seen in mV
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 movff EEDATA,sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
92 read_int_eeprom d'41'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
93 movff EEDATA,sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
95 movlw LOW d'2000' ; must be greater then 2000mV...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
96 movwf sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
97 movlw HIGH d'2000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
98 movwf sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
99 call sub16 ; sub_c = sub_a - sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
100 btfss neg_flag ; neg_flag=1 if eeprom40:41 < 2000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
101 bsf initialize_battery1 ; battery need to be initialised
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
103 movlw LOW d'4500' ; must be lower then 4500mV...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
104 movwf sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
105 movlw HIGH d'4500'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
106 movwf sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
107 call sub16 ; sub_c = sub_a - sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
108 btfss neg_flag ; neg_flag=1 if eeprom40:41 < 4500
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
109 bsf initialize_battery2 ; battery need to be initialised
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
110
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
111 btfss initialize_battery1 ; battery need to be initialised?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
112 bra get_battery_no_init ; No, we have already valid values, just check for new extremas
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114 btfss initialize_battery2 ; battery need to be initialised?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115 bra get_battery_no_init ; No, we have already valid values, just check for new extremas
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
116
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
117 ; Init EEPROM for battery control
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
118 ; Reset lowest battery seen
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 movlw LOW d'4200' ; reset to 4.2V
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
120 movwf EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
121 write_int_eeprom d'40'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122 movlw HIGH d'4200' ; reset to 4.2V
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
123 movwf EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 write_int_eeprom d'41'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125 movff month,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 write_int_eeprom d'42'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127 movff day,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128 write_int_eeprom d'43'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129 movff year,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
130 write_int_eeprom d'44'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 movff temperature+0,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132 write_int_eeprom d'45'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
133 movff temperature+1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134 write_int_eeprom d'46'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135 ; Reset charge statistics
53
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
136 clrf EEDATA
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
137 write_int_eeprom d'47' ; last complete charge
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
138 write_int_eeprom d'48' ; last complete charge
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
139 write_int_eeprom d'49' ; last complete charge
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
140 write_int_eeprom d'50' ; total cycles
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
141 write_int_eeprom d'51' ; total cycles
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
142 write_int_eeprom d'52' ; total complete cycles
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
143 write_int_eeprom d'53' ; total complete cycles
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144 ; Reset temperature extremas
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145 movff temperature+0,EEDATA ; Reset mimimum extrema
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
146 write_int_eeprom d'54'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
147 movff temperature+1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148 write_int_eeprom d'55'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149 movff month,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150 write_int_eeprom d'56'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151 movff day,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152 write_int_eeprom d'57'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 movff year,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
154 write_int_eeprom d'58'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
155 movff temperature+0,EEDATA ; Reset maximum extrema
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
156 write_int_eeprom d'59'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
157 movff temperature+1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
158 write_int_eeprom d'60'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
159 movff month,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
160 write_int_eeprom d'61'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161 movff day,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
162 write_int_eeprom d'62'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 movff year,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164 write_int_eeprom d'63'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
166 get_battery_no_init:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167 read_int_eeprom d'40' ; get lowest battery voltage seen in mV
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168 movff EEDATA,sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169 read_int_eeprom d'41'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170 movff EEDATA,sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171 movff batt_voltage+0,sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 movff batt_voltage+1,sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173 call sub16 ; sub_c = sub_a - sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 btfss neg_flag ; new lowest battery voltage?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 return ; no, quit routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 ; Yes, store new value together with the date and temperature values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 movff batt_voltage+0,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
178 write_int_eeprom d'40'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
179 movff batt_voltage+1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
180 write_int_eeprom d'41'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 movff month,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 write_int_eeprom d'42'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183 movff day,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 write_int_eeprom d'43'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185 movff year,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
186 write_int_eeprom d'44'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
187 movff temperature+0,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
188 write_int_eeprom d'45'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
189 movff temperature+1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 write_int_eeprom d'46'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193 RTCinit: ; resets RTC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 movlw 0x80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 movwf TMR1H
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196 clrf TMR1L
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198 ; Reset RTC if any part of the time/date is out of range
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
199 movlw d'60' ; Limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200 cpfslt secs ; Check part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 bra RTCinit2 ; Reset time...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202 movlw d'60' ; Limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
203 cpfslt mins ; Check part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204 bra RTCinit2 ; Reset time...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 movlw d'24' ; Limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
206 cpfslt hours ; Check part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
207 bra RTCinit2 ; Reset time...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208 movlw d'32' ; Limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
209 cpfslt day ; Check part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
210 bra RTCinit2 ; Reset time...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
211 movlw d'12' ; Limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 cpfslt month ; Check part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
213 bra RTCinit2 ; Reset time...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
214 movlw d'100' ; Limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
215 cpfslt year ; Check part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
216 bra RTCinit2 ; Reset time...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
218 bsf PIE1, TMR1IE
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
219 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
220
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221 RTCinit2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222 movlw .00
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223 movwf secs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 movlw .00
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225 movwf mins
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
226 movlw .12
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 movwf hours
53
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
228 movlw .1
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 movwf day
53
263348f83485 1.70 cleaning the code
heinrichsweikamp
parents: 21
diff changeset
230 movlw .8
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
231 movwf month
12
588a969a0cae 1.53 beta rc
heinrichsweikamp
parents: 0
diff changeset
232 movlw .10
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233 movwf year
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 bsf PIE1, TMR1IE
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235 return