comparison code_part1/OSTC_code_asm_part1/interface.asm @ 395:0e0cf4701c17

Merge with 64kByte Logbook
author JeanDo
date Thu, 23 Jun 2011 01:37:59 +0200
parents ed26990716fe
children c512a868937c
comparison
equal deleted inserted replaced
369:93c0cb14b0d2 395:0e0cf4701c17
140 movwf TXREG 140 movwf TXREG
141 141
142 DISPLAYTEXT .16 ; "Start" 142 DISPLAYTEXT .16 ; "Start"
143 143
144 call get_free_EEPROM_location ; 144 call get_free_EEPROM_location ;
145
145 movlw d'1' ; increase 146 movlw d'1' ; increase
146 addwf eeprom_address+0,F 147 addwf eeprom_address+0,F
147 movlw d'0' 148 movlw d'0'
148 addwfc eeprom_address+1,F 149 addwfc eeprom_address+1,F
149 150
151 ;For debug only
152 ;clrf eeprom_address+0,F
153 ;clrf eeprom_address+1,F
154
150 DISPLAYTEXT .17 ; "Data" 155 DISPLAYTEXT .17 ; "Data"
151 156
152 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM 157 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM
153 158
154 call rs232_wait_tx ; wait for UART 159 call rs232_wait_tx ; wait for UART
165 movlw softwareversion_y ; Softwareversion 170 movlw softwareversion_y ; Softwareversion
166 movwf TXREG 171 movwf TXREG
167 172
168 DISPLAYTEXT .18 ; "Header" 173 DISPLAYTEXT .18 ; "Header"
169 174
170 clrf uart1_temp ; low address counter 175 setf uart1_temp ; low address counter
171 clrf uart2_temp ; high address counter 176 setf uart2_temp ; high address counter
172 177
173 menu_interface3: 178 menu_interface3:
174 bsf SSPCON2,SEN ; Start condition 179 bsf SSPCON2,SEN ; Start condition
175 call WaitMSSP 180 call WaitMSSP
176 181
177 movlw b'10100110' ; Bit0=0: WRITE, Bit0=1: READ 182 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
183 btfss eeprom_address+1,7 ; Access Block2?
184 movlw b'10100110' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
178 movwf SSPBUF ; control byte 185 movwf SSPBUF ; control byte
179 call WaitMSSP 186 call WaitMSSP
180 btfsc SSPCON2,ACKSTAT 187 btfsc SSPCON2,ACKSTAT
181 bra menu_interface3 ; No Ack, try again! 188 bra menu_interface3 ; No Ack, try again!
182 189
187 call WaitMSSP 194 call WaitMSSP
188 call I2C_WaitforACK 195 call I2C_WaitforACK
189 bsf SSPCON2,RSEN ; Start condition 196 bsf SSPCON2,RSEN ; Start condition
190 call WaitMSSP 197 call WaitMSSP
191 198
192 movlw b'10100111' ; Bit0=0: WRITE, Bit0=1: READ 199 movlw b'10101111' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
200 btfss eeprom_address+1,7 ; Access Block2?
201 movlw b'10100111' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
202
193 movwf SSPBUF ; control byte 203 movwf SSPBUF ; control byte
194 call WaitMSSP 204 call WaitMSSP
195 call I2C_WaitforACK 205 call I2C_WaitforACK
196 206
197 DISPLAYTEXT .19 ; "Profile" 207 DISPLAYTEXT .19 ; "Profile"
198 208
199 menu_interface2: 209 menu_interface2:
200 call rs232_wait_tx ; wait for UART 210 call rs232_wait_tx ; wait for UART
201
202 bsf SSPCON2, RCEN ; Enable recieve mode
203 call WaitMSSP
204
205 movff SSPBUF, TXREG
206 211
207 movlw d'1' 212 movlw d'1'
208 addwf uart1_temp,F 213 addwf uart1_temp,F
209 movlw d'0' 214 movlw d'0'
210 addwfc uart2_temp,F 215 addwfc uart2_temp,F
211 216
212 btfsc uart2_temp,7 ; 32KB done? 217 ; Slow but safe...
213 bra menu_interface4 ; Yes 218 call I2CREAD2 ; same as I2CREAD but with automatic address increase
214 219 movff SSPBUF, TXREG
215 bsf SSPCON2, ACKEN ; Ack 220
216 call WaitMSSP 221 movlw 0xFF
217 bra menu_interface2 ; go on 222 cpfseq uart2_temp ;=0xFFFF?
218 223 bra menu_interface2 ; No, continue
219 menu_interface4: 224 cpfseq uart1_temp ;=0xFFFF?
220 bsf SSPCON2, PEN ; Stop 225 bra menu_interface2 ; No, continue
221 call WaitMSSP 226
222
223 DISPLAYTEXT .20 ; Done. 227 DISPLAYTEXT .20 ; Done.
224 228
225 WAITMS d'250' 229 WAITMS d'250'
226 bcf LED_blue 230 bcf LED_blue
227 bsf PIE1,RCIE ; Interrupt for RS232 231 bsf PIE1,RCIE ; Interrupt for RS232