annotate code_part1/OSTC_code_asm_part1/tempcomp.asm @ 48:ebc5abda180d

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