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