comparison code_part1/OSTC_code_asm_part1/interface.asm @ 351:5c186a72cb5d 64kByte Logbook

Debugging the new logbook format, 64kB download routine
author heinrichsweikamp
date Tue, 31 May 2011 22:09:17 +0200
parents 7250ca7c8d24
children ed26990716fe
comparison
equal deleted inserted replaced
350:7250ca7c8d24 351:5c186a72cb5d
165 movlw softwareversion_y ; Softwareversion 165 movlw softwareversion_y ; Softwareversion
166 movwf TXREG 166 movwf TXREG
167 167
168 DISPLAYTEXT .18 ; "Header" 168 DISPLAYTEXT .18 ; "Header"
169 169
170 clrf uart1_temp ; low address counter 170 setf uart1_temp ; low address counter
171 clrf uart2_temp ; high address counter 171 setf uart2_temp ; high address counter
172 172
173 menu_interface3: 173 menu_interface3:
174 bsf SSPCON2,SEN ; Start condition 174 bsf SSPCON2,SEN ; Start condition
175 call WaitMSSP 175 call WaitMSSP
176 176
177 movlw b'10100110' ; Bit0=0: WRITE, Bit0=1: READ 177 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
178 btfss eeprom_address+1,7 ; Access Block2?
179 movlw b'10100110' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
178 movwf SSPBUF ; control byte 180 movwf SSPBUF ; control byte
179 call WaitMSSP 181 call WaitMSSP
180 btfsc SSPCON2,ACKSTAT 182 btfsc SSPCON2,ACKSTAT
181 bra menu_interface3 ; No Ack, try again! 183 bra menu_interface3 ; No Ack, try again!
182 184
187 call WaitMSSP 189 call WaitMSSP
188 call I2C_WaitforACK 190 call I2C_WaitforACK
189 bsf SSPCON2,RSEN ; Start condition 191 bsf SSPCON2,RSEN ; Start condition
190 call WaitMSSP 192 call WaitMSSP
191 193
192 movlw b'10100111' ; Bit0=0: WRITE, Bit0=1: READ 194 movlw b'10101111' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
195 btfss eeprom_address+1,7 ; Access Block2?
196 movlw b'10100111' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
197
193 movwf SSPBUF ; control byte 198 movwf SSPBUF ; control byte
194 call WaitMSSP 199 call WaitMSSP
195 call I2C_WaitforACK 200 call I2C_WaitforACK
196 201
197 DISPLAYTEXT .19 ; "Profile" 202 DISPLAYTEXT .19 ; "Profile"
198 203
199 menu_interface2: 204 menu_interface2:
200 call rs232_wait_tx ; wait for UART 205 call rs232_wait_tx ; wait for UART
201
202 bsf SSPCON2, RCEN ; Enable recieve mode
203 call WaitMSSP
204
205 movff SSPBUF, TXREG
206 206
207 movlw d'1' 207 movlw d'1'
208 addwf uart1_temp,F 208 addwf uart1_temp,F
209 movlw d'0' 209 movlw d'0'
210 addwfc uart2_temp,F 210 addwfc uart2_temp,F
211 211
212 btfsc uart2_temp,7 ; 32KB done? 212 ; Slow but safe...
213 bra menu_interface4 ; Yes 213 call I2CREAD2 ; same as I2CREAD but with automatic address increase
214
215 bsf SSPCON2, ACKEN ; Ack
216 call WaitMSSP
217 bra menu_interface2 ; go on
218
219 menu_interface4:
220 bsf SSPCON2, PEN ; Stop
221 call WaitMSSP
222
223
224 clrf uart1_temp ; low address counter
225 clrf uart2_temp ; high address counter
226
227 menu_interface5: ;Send another 32kB from Block2....
228 bsf SSPCON2,SEN ; Start condition
229 call WaitMSSP
230
231 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ
232 movwf SSPBUF ; control byte
233 call WaitMSSP
234 btfsc SSPCON2,ACKSTAT
235 bra menu_interface5 ; No Ack, try again!
236
237 movff eeprom_address+1,SSPBUF ; High Address byte
238 call WaitMSSP
239 call I2C_WaitforACK
240 movff eeprom_address+0,SSPBUF ; Low Address byte
241 call WaitMSSP
242 call I2C_WaitforACK
243 bsf SSPCON2,RSEN ; Start condition
244 call WaitMSSP
245
246 movlw b'10101111' ; Bit0=0: WRITE, Bit0=1: READ
247 movwf SSPBUF ; control byte
248 call WaitMSSP
249 call I2C_WaitforACK
250
251 menu_interface6:
252 call rs232_wait_tx ; wait for UART
253
254 bsf SSPCON2, RCEN ; Enable recieve mode
255 call WaitMSSP
256
257 movff SSPBUF, TXREG 214 movff SSPBUF, TXREG
258 215
259 movlw d'1' 216 movlw 0xFF
260 addwf uart1_temp,F 217 cpfseq uart2_temp ;=0xFFFF?
261 movlw d'0' 218 bra menu_interface2 ; No, continue
262 addwfc uart2_temp,F 219 cpfseq uart1_temp ;=0xFFFF?
263 220 bra menu_interface2 ; No, continue
264 btfsc uart2_temp,7 ; 32KB done?
265 bra menu_interface7 ; Yes
266
267 bsf SSPCON2, ACKEN ; Ack
268 call WaitMSSP
269 bra menu_interface6 ; go on
270
271 menu_interface7:
272 bsf SSPCON2, PEN ; Stop
273 call WaitMSSP
274 221
275 DISPLAYTEXT .20 ; Done. 222 DISPLAYTEXT .20 ; Done.
276 223
277 WAITMS d'250' 224 WAITMS d'250'
278 bcf LED_blue 225 bcf LED_blue