Mercurial > public > hwos_code
comparison src/eeprom_rs232.asm @ 133:939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
NEW: Store tissue load, date and time, surface interval, desat. time and nofly time every hour and reload them after battery change
author | heinrichsweikamp |
---|---|
date | Mon, 14 Jul 2014 15:17:07 +0200 |
parents | f3062a611eef |
children | 5cb177f0948a |
comparison
equal
deleted
inserted
replaced
132:ec0b1e829399 | 133:939f1e83c4c2 |
---|---|
8 ;============================================================================= | 8 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2011-08-06 : [mH] moving from OSTC code | 10 ; 2011-08-06 : [mH] moving from OSTC code |
11 | 11 |
12 #include "ostc3.inc" | 12 #include "ostc3.inc" |
13 #include "start.inc" | |
14 #include "tft.inc" | |
15 #include "wait.inc" | 13 #include "wait.inc" |
16 #include "strings.inc" | |
17 #include "convert.inc" | |
18 #include "adc_lightsensor.inc" | |
19 #include "math.inc" | |
20 | 14 |
21 ;============================================================================= | 15 ;============================================================================= |
22 eeprom code 0xF00000+0x10 | 16 eeprom code 0xF00000+0x10 |
23 ; Skip SERIAL number. Should not be overwritten. | 17 ; Skip SERIAL number. Should not be overwritten. |
24 global eeprom_serial_save, eeprom_opt_backup | 18 global eeprom_serial_save, eeprom_opt_backup |
59 write_eeprom: | 53 write_eeprom: |
60 bcf EECON1,EEPGD | 54 bcf EECON1,EEPGD |
61 bcf EECON1,CFGS | 55 bcf EECON1,CFGS |
62 bsf EECON1,WREN | 56 bsf EECON1,WREN |
63 | 57 |
64 bcf INTCON,GIE ; even the RTC will be delayed for the next 5 instructions... | 58 bcf INTCON,GIE ; Disable interrups for the next 5 instructions |
65 movlw 0x55 | 59 movlw 0x55 |
66 movwf EECON2 | 60 movwf EECON2 |
67 movlw 0xAA | 61 movlw 0xAA |
68 movwf EECON2 | 62 movwf EECON2 |
69 bsf EECON1,WR | 63 bsf EECON1,WR |
158 | 152 |
159 ;============================================================================= | 153 ;============================================================================= |
160 global enable_rs232 | 154 global enable_rs232 |
161 enable_rs232: | 155 enable_rs232: |
162 bcf TRISC,6 ; Output | 156 bcf TRISC,6 ; Output |
163 bsf TRISC,7 ; Input | |
164 call speed_normal ; 16MHz | 157 call speed_normal ; 16MHz |
165 enable_rs232_2: | 158 enable_rs232_2: |
166 movlw T2CON_NORMAL | 159 movlw T2CON_NORMAL |
167 cpfseq T2CON | 160 cpfseq T2CON |
168 bra enable_rs232_2 ; Wait until speed is normal | 161 bra enable_rs232_2 ; Wait until speed is normal |
183 global disable_rs232 | 176 global disable_rs232 |
184 disable_rs232: | 177 disable_rs232: |
185 clrf RCSTA1 | 178 clrf RCSTA1 |
186 clrf TXSTA1 ; UART disable | 179 clrf TXSTA1 ; UART disable |
187 bsf TRISC,6 ; Input | 180 bsf TRISC,6 ; Input |
188 bsf TRISC,7 ; Input | |
189 return | 181 return |
190 | 182 |
191 global rs232_wait_tx | 183 global rs232_wait_tx |
192 rs232_wait_tx: | 184 rs232_wait_tx: |
193 btfsc TXSTA1,TRMT ; Transmit Shift Register empty? | 185 btfsc TXSTA1,TRMT ; Transmit Shift Register empty? |
209 banksel common | 201 banksel common |
210 return ; Done. | 202 return ; Done. |
211 | 203 |
212 global rs232_get_byte | 204 global rs232_get_byte |
213 rs232_get_byte: | 205 rs232_get_byte: |
214 bcf PIR1,RCIF ; clear flag | |
215 bcf rs232_recieve_overflow ; clear flag | 206 bcf rs232_recieve_overflow ; clear flag |
216 clrf uart1_temp | 207 clrf uart1_temp |
217 clrf uart2_temp | 208 clrf uart2_temp |
218 rs232_get_byte2: | 209 rs232_get_byte2: |
219 btfsc PIR1,RCIF ; data arrived? | 210 btfsc PIR1,RCIF ; data arrived? |
220 return | 211 return |
221 ; bra rs232_get_byte3 | |
222 | |
223 decfsz uart2_temp,F | 212 decfsz uart2_temp,F |
224 bra rs232_get_byte2 | 213 bra rs232_get_byte2 |
225 decfsz uart1_temp,F | 214 decfsz uart1_temp,F |
226 bra rs232_get_byte2 | 215 bra rs232_get_byte2 |
227 ; timeout occoured (about 20ms) | 216 ; timeout occoured (about 20ms) |
228 bsf rs232_recieve_overflow ; set flag | 217 bsf rs232_recieve_overflow ; set flag |
229 ;rs232_get_byte3: | |
230 bcf RCSTA1,CREN ; Clear receiver status | 218 bcf RCSTA1,CREN ; Clear receiver status |
231 bsf RCSTA1,CREN | 219 bsf RCSTA1,CREN |
232 return ; and return anyway | 220 return ; and return anyway |
233 | 221 |
234 END | 222 END |