Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/tempcomp.asm @ 4:2b5c52ae3923
1.52 beta rc
author | heinrichsweikamp |
---|---|
date | Sun, 14 Feb 2010 20:09:25 +0100 |
parents | 96a35aeda5f2 |
children | cd5b650920f6 |
comparison
equal
deleted
inserted
replaced
3:3cf8af30b36e | 4:2b5c52ae3923 |
---|---|
59 | 59 |
60 | 60 |
61 | 61 |
62 | 62 |
63 compensate_temperature: | 63 compensate_temperature: |
64 | |
65 bcf uart_compensate_temp ; clear flag | 64 bcf uart_compensate_temp ; clear flag |
66 | |
67 bcf PIE1,RCIE ; no interrupt for UART | 65 bcf PIE1,RCIE ; no interrupt for UART |
68 | 66 ; |
69 call set_LEDusb ; LEDusb ON | 67 ; call set_LEDusb ; LEDusb ON |
70 | 68 ; |
71 bcf PIR1,RCIF ; clear flag | 69 ; bcf PIR1,RCIF ; clear flag |
72 | 70 ; |
73 | 71 ; |
74 | 72 ; |
75 movlw "f" ; send echo | 73 ; movlw "f" ; send echo |
76 | 74 ; |
77 movwf TXREG | 75 ; movwf TXREG |
78 | 76 ; |
79 call rs232_wait_tx ; wait for UART | 77 ; call rs232_wait_tx ; wait for UART |
80 | 78 ; |
81 | 79 ; |
82 | 80 ; |
83 call rs232_get_byte ; low byte | 81 ; call rs232_get_byte ; low byte |
84 | 82 ; |
85 movff RCREG, lo | 83 ; movff RCREG, lo |
86 | 84 ; |
87 | 85 ; |
88 | 86 ; |
89 call rs232_get_byte ; high byte | 87 ; call rs232_get_byte ; high byte |
90 | 88 ; |
91 movff RCREG, hi | 89 ; movff RCREG, hi |
92 | 90 ; |
93 | 91 ; |
94 | 92 ; |
95 clrf temperature_correction ; wait for uncompensated temperature value! | 93 ; clrf temperature_correction ; wait for uncompensated temperature value! |
96 | 94 ; |
97 WAITMS d'250' ; wait for new temperature | 95 ; WAITMS d'250' ; wait for new temperature |
98 | 96 ; |
99 WAITMS d'250' | 97 ; WAITMS d'250' |
100 | 98 ; |
101 WAITMS d'250' | 99 ; WAITMS d'250' |
102 | 100 ; |
103 WAITMS d'250' | 101 ; WAITMS d'250' |
104 | 102 ; |
105 | 103 ; |
106 | 104 ; |
107 movff lo,sub_a+0 ; calculate difference | 105 ; movff lo,sub_a+0 ; calculate difference |
108 | 106 ; |
109 movff hi,sub_a+1 | 107 ; movff hi,sub_a+1 |
110 | 108 ; |
111 movff temperature+0, sub_b+0 | 109 ; movff temperature+0, sub_b+0 |
112 | 110 ; |
113 movff temperature+1, sub_b+1 | 111 ; movff temperature+1, sub_b+1 |
114 | 112 ; |
115 call sub16 ; sub_c = sub_a - sub_b | 113 ; call sub16 ; sub_c = sub_a - sub_b |
116 | 114 ; |
117 | 115 ; |
118 | 116 ; |
119 movf sub_c+0,W | 117 ; movf sub_c+0,W |
120 | 118 ; |
121 btfsc neg_flag ; compensate negative? | 119 ; btfsc neg_flag ; compensate negative? |
122 | 120 ; |
123 movlw d'0' ; use zero compensation! | 121 ; movlw d'0' ; use zero compensation! |
124 | 122 ; |
125 movwf sub_c+0 | 123 ; movwf sub_c+0 |
126 | 124 ; |
127 | 125 ; |
128 | 126 ; |
129 movff sub_c+0,TXREG ; Send answer | 127 ; movff sub_c+0,TXREG ; Send answer |
130 | 128 ; |
131 | 129 ; |
132 | 130 ; |
133 movff sub_c+0,EEDATA ; store low byte only! | 131 ; movff sub_c+0,EEDATA ; store low byte only! |
134 | 132 ; |
135 movff sub_c+0,temperature_correction ; no reboot required then... | 133 ; movff sub_c+0,temperature_correction ; no reboot required then... |
136 | 134 ; |
137 movlw 0x01 | 135 ; movlw 0x01 |
138 | 136 ; |
139 movwf EEADRH | 137 ; movwf EEADRH |
140 | 138 ; |
141 movlw 0x00 | 139 ; movlw 0x00 |
142 | 140 ; |
143 movwf EEADR | 141 ; movwf EEADR |
144 | 142 ; |
145 call write_eeprom ; stores in internal eeprom | 143 ; call write_eeprom ; stores in internal eeprom |
146 | 144 ; |
147 | 145 ; |
148 | 146 ; |
149 movlw 0x00 | 147 ; movlw 0x00 |
150 | 148 ; |
151 movwf EEADRH ; reset high address byte | 149 ; movwf EEADRH ; reset high address byte |
152 | 150 ; |
153 | 151 ; |
154 | 152 ; |
155 call clear_LEDusb ; LEDusb OFF | 153 ; call clear_LEDusb ; LEDusb OFF |
156 | 154 ; |
157 bcf PIR1,RCIF ; clear flag | 155 ; bcf PIR1,RCIF ; clear flag |
158 | |
159 bsf PIE1,RCIE ; enable interrupt for UART | 156 bsf PIE1,RCIE ; enable interrupt for UART |
160 | |
161 goto surfloop_loop ; return to surface loop | 157 goto surfloop_loop ; return to surface loop |
162 | 158 |