annotate code_part1/OSTC_code_asm_part1/tempcomp.asm @ 57:152fbe7f121d

small update simulator
author heinrichsweikamp
date Tue, 03 Aug 2010 21:42:43 +0200
parents cd5b650920f6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
cd5b650920f6 1.70...
heinrichsweikamp
parents: 4
diff changeset
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
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
2 ; call set_LEDusb ; LEDusb ON ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
3 ; bcf PIR1,RCIF ; clear flag ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
4 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
5 ; movlw "f" ; send echo ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
6 ; movwf TXREG ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
7 ; call rs232_wait_tx ; wait for UART ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
8 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
9 ; call rs232_get_byte ; low byte ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
10 ; movff RCREG, lo ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
11 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
12 ; call rs232_get_byte ; high byte ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
13 ; movff RCREG, hi ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
14 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
15 ; clrf temperature_correction ; wait for uncompensated temperature value! ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
16 ; WAITMS d'250' ; wait for new temperature ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
17 ; WAITMS d'250' ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
18 ; WAITMS d'250' ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
19 ; WAITMS d'250' ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
20 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
21 ; movff lo,sub_a+0 ; calculate difference ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
22 ; movff hi,sub_a+1 ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
23 ; movff temperature+0, sub_b+0 ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
24 ; movff temperature+1, sub_b+1 ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
25 ; call sub16 ; sub_c = sub_a - sub_b ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
26 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
27 ; movf sub_c+0,W ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
28 ; btfsc neg_flag ; compensate negative? ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
29 ; movlw d'0' ; use zero compensation! ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
30 ; movwf sub_c+0 ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
31 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
32 ; movff sub_c+0,TXREG ; Send answer ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
33 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
34 ; movff sub_c+0,EEDATA ; store low byte only! ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
35 ; movff sub_c+0,temperature_correction ; no reboot required then... ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
36 ; movlw 0x01 ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
37 ; movwf EEADRH ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
38 ; movlw 0x00 ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
39 ; movwf EEADR ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
40 ; call write_eeprom ; stores in internal eeprom ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
41 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
42 ; movlw 0x00 ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
43 ; movwf EEADRH ; reset high address byte ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
44 ; ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
45 ; call clear_LEDusb ; LEDusb OFF ;
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
46 ; bcf PIR1,RCIF ; clear flag bsf PIE1,RCIE ; enable interrupt for UART goto surfloop_loop ; return to surface loop