comparison code_part1/OSTC_code_asm_part1/tempcomp.asm @ 0:96a35aeda5f2

Initial setup
author heinrichsweikamp
date Tue, 12 Jan 2010 15:05:59 +0100
parents
children 2b5c52ae3923
comparison
equal deleted inserted replaced
-1:000000000000 0:96a35aeda5f2
1
2
3 ; OSTC - diving computer code
4
5 ; Copyright (C) 2008 HeinrichsWeikamp GbR
6
7
8
9 ; This program is free software: you can redistribute it and/or modify
10
11 ; it under the terms of the GNU General Public License as published by
12
13 ; the Free Software Foundation, either version 3 of the License, or
14
15 ; (at your option) any later version.
16
17
18
19 ; This program is distributed in the hope that it will be useful,
20
21 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
22
23 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
25 ; GNU General Public License for more details.
26
27
28
29 ; You should have received a copy of the GNU General Public License
30
31 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
32
33
34
35
36
37 ; routine for extra temperature compensation
38
39 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
40
41 ; written: 01/12/08
42
43 ; last updated: 08/08/31
44
45 ; known bugs:
46
47 ; ToDo:
48
49
50
51 ; routine echoes the "f" command as ready signal
52
53 ; PC has to send 2 bytes containing the actual temperature in 0.1C
54
55 ; Byte1: low
56
57 ; Byte2: high
58
59
60
61
62
63 compensate_temperature:
64
65 bcf uart_compensate_temp ; clear flag
66
67 bcf PIE1,RCIE ; no interrupt for UART
68
69 call set_LEDusb ; LEDusb ON
70
71 bcf PIR1,RCIF ; clear flag
72
73
74
75 movlw "f" ; send echo
76
77 movwf TXREG
78
79 call rs232_wait_tx ; wait for UART
80
81
82
83 call rs232_get_byte ; low byte
84
85 movff RCREG, lo
86
87
88
89 call rs232_get_byte ; high byte
90
91 movff RCREG, hi
92
93
94
95 clrf temperature_correction ; wait for uncompensated temperature value!
96
97 WAITMS d'250' ; wait for new temperature
98
99 WAITMS d'250'
100
101 WAITMS d'250'
102
103 WAITMS d'250'
104
105
106
107 movff lo,sub_a+0 ; calculate difference
108
109 movff hi,sub_a+1
110
111 movff temperature+0, sub_b+0
112
113 movff temperature+1, sub_b+1
114
115 call sub16 ; sub_c = sub_a - sub_b
116
117
118
119 movf sub_c+0,W
120
121 btfsc neg_flag ; compensate negative?
122
123 movlw d'0' ; use zero compensation!
124
125 movwf sub_c+0
126
127
128
129 movff sub_c+0,TXREG ; Send answer
130
131
132
133 movff sub_c+0,EEDATA ; store low byte only!
134
135 movff sub_c+0,temperature_correction ; no reboot required then...
136
137 movlw 0x01
138
139 movwf EEADRH
140
141 movlw 0x00
142
143 movwf EEADR
144
145 call write_eeprom ; stores in internal eeprom
146
147
148
149 movlw 0x00
150
151 movwf EEADRH ; reset high address byte
152
153
154
155 call clear_LEDusb ; LEDusb OFF
156
157 bcf PIR1,RCIF ; clear flag
158
159 bsf PIE1,RCIE ; enable interrupt for UART
160
161 goto surfloop_loop ; return to surface loop
162