0
|
1
|
|
2 ; OSTC - diving computer code
|
|
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR
|
|
4
|
|
5 ; This program is free software: you can redistribute it and/or modify
|
|
6 ; it under the terms of the GNU General Public License as published by
|
|
7 ; the Free Software Foundation, either version 3 of the License, or
|
|
8 ; (at your option) any later version.
|
|
9
|
|
10 ; This program is distributed in the hope that it will be useful,
|
|
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 ; GNU General Public License for more details.
|
|
14
|
|
15 ; You should have received a copy of the GNU General Public License
|
|
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
|
18
|
|
19 ; routine for extra temperature compensation
|
|
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
|
|
21 ; written: 01/12/08
|
|
22 ; last updated: 08/08/31
|
|
23 ; known bugs:
|
|
24 ; ToDo:
|
|
25
|
|
26 ; routine echoes the "f" command as ready signal
|
|
27 ; PC has to send 2 bytes containing the actual temperature in 0.1C
|
|
28 ; Byte1: low
|
|
29 ; Byte2: high
|
|
30
|
|
31
|
4
|
32 compensate_temperature:
bcf uart_compensate_temp ; clear flag
bcf PIE1,RCIE ; no interrupt for UART
;
|
|
33 ; call set_LEDusb ; LEDusb ON
;
|
|
34 ; bcf PIR1,RCIF ; clear flag
;
|
|
35 ;
;
|
|
36 ; movlw "f" ; send echo
;
|
|
37 ; movwf TXREG
;
|
|
38 ; call rs232_wait_tx ; wait for UART
;
|
|
39 ;
;
|
|
40 ; call rs232_get_byte ; low byte
;
|
|
41 ; movff RCREG, lo
;
|
|
42 ;
;
|
|
43 ; call rs232_get_byte ; high byte
;
|
|
44 ; movff RCREG, hi
;
|
|
45 ;
;
|
|
46 ; clrf temperature_correction ; wait for uncompensated temperature value!
;
|
|
47 ; WAITMS d'250' ; wait for new temperature
;
|
|
48 ; WAITMS d'250'
;
|
|
49 ; WAITMS d'250'
;
|
|
50 ; WAITMS d'250'
;
|
|
51 ;
;
|
|
52 ; movff lo,sub_a+0 ; calculate difference
;
|
|
53 ; movff hi,sub_a+1
;
|
|
54 ; movff temperature+0, sub_b+0
;
|
|
55 ; movff temperature+1, sub_b+1
;
|
|
56 ; call sub16 ; sub_c = sub_a - sub_b
;
|
|
57 ;
;
|
|
58 ; movf sub_c+0,W
;
|
|
59 ; btfsc neg_flag ; compensate negative?
;
|
|
60 ; movlw d'0' ; use zero compensation!
;
|
|
61 ; movwf sub_c+0
;
|
|
62 ;
;
|
|
63 ; movff sub_c+0,TXREG ; Send answer
;
|
|
64 ;
;
|
|
65 ; movff sub_c+0,EEDATA ; store low byte only!
;
|
|
66 ; movff sub_c+0,temperature_correction ; no reboot required then...
;
|
|
67 ; movlw 0x01
;
|
|
68 ; movwf EEADRH
;
|
|
69 ; movlw 0x00
;
|
|
70 ; movwf EEADR
;
|
|
71 ; call write_eeprom ; stores in internal eeprom
;
|
|
72 ;
;
|
|
73 ; movlw 0x00
;
|
|
74 ; movwf EEADRH ; reset high address byte
;
|
|
75 ;
;
|
|
76 ; call clear_LEDusb ; LEDusb OFF
;
|
|
77 ; bcf PIR1,RCIF ; clear flag
bsf PIE1,RCIE ; enable interrupt for UART
goto surfloop_loop ; return to surface loop
|