Mercurial > public > hwos_code
annotate src/external_flash.asm @ 391:682199d87b5c
add profile version to compact headers
author | heinrichsweikamp |
---|---|
date | Mon, 02 Nov 2015 17:48:20 +0100 |
parents | eb758a5b44eb |
children | 35bdfd89323c |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File external_flash.asm | |
4 ; | |
5 ; External flash | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-12 : [mH] creation | |
11 | |
275 | 12 #include "hwos.inc" |
0 | 13 #include "wait.inc" |
14 | |
15 basic CODE | |
16 ;============================================================================= | |
17 | |
18 global incf_ext_flash_address_p1 | |
19 incf_ext_flash_address_p1: ; Increase by one | |
20 movlw .1 | |
21 | |
22 global incf_ext_flash_address0 | |
23 incf_ext_flash_address0: | |
24 addwf ext_flash_address+0,F ; increase address | |
25 movlw d'0' | |
26 addwfc ext_flash_address+1,F | |
27 addwfc ext_flash_address+2,F | |
28 | |
29 movlw 0x40 | |
30 cpfseq ext_flash_address+2 ; at address 40FFFF? | |
31 return ; No, return | |
167 | 32 ; clrf ext_flash_address+0 |
33 ; clrf ext_flash_address+1 | |
34 clrf ext_flash_address+2 ; Yes, rollover to 0x000000 | |
0 | 35 return |
36 | |
37 global incf_ext_flash_address0_p1_0x20 | |
38 incf_ext_flash_address0_p1_0x20: ; Increase by one | |
39 movlw .1 | |
40 | |
41 global incf_ext_flash_address0_0x20 | |
42 incf_ext_flash_address0_0x20: ; with roll-over at 0x200000 to 0x000000 | |
43 addwf ext_flash_address+0,F ; increase address | |
44 movlw d'0' | |
45 addwfc ext_flash_address+1,F | |
46 addwfc ext_flash_address+2,F | |
47 | |
48 movlw 0x20 | |
49 cpfseq ext_flash_address+2 ; at address 0x200000? | |
50 return ; No, return | |
167 | 51 ; clrf ext_flash_address+0 |
52 ; clrf ext_flash_address+1 | |
53 clrf ext_flash_address+2 ; Yes, rollover to 0x000000 | |
0 | 54 return |
55 | |
56 global decf_ext_flash_address0 | |
57 decf_ext_flash_address0: | |
58 subwf ext_flash_address+0,F ; decrease address: do a 16-8bits substract. | |
59 movlw d'0' | |
60 subwfb ext_flash_address+1,F | |
61 movlw d'0' | |
62 subwfb ext_flash_address+2,F | |
63 | |
64 btfss ext_flash_address+2,7 ; Rollover to 0xFFFFFF? | |
65 return ; No, return | |
66 clrf ext_flash_address+2 ; Set to 0x00FFFFF | |
67 setf ext_flash_address+1 | |
68 setf ext_flash_address+0 | |
69 return | |
70 | |
71 global ext_flash_power_down | |
72 ext_flash_power_down: | |
73 movlw 0x04 ; Write disable | |
74 rcall write_spi | |
75 bsf flash_ncs ; CS=1 | |
76 return | |
77 | |
78 global ext_flash_byte_read_plus ; Return data read in WREG and SSP2BUF and | |
79 ext_flash_byte_read_plus: ; increase address after read | |
80 rcall ext_flash_byte_read | |
81 movwf temp1 ; store received data | |
82 bra incf_ext_flash_address_p1 ; +1 and return | |
83 | |
84 global ext_flash_byte_read_plus_0x20; Return data read in WREG and SSP2BUF and | |
85 ext_flash_byte_read_plus_0x20: ; increase address after read with banking at 0x200000 | |
86 rcall ext_flash_byte_read | |
87 movwf temp1 ; store received data | |
88 bra incf_ext_flash_address0_p1_0x20 ;+1 and return | |
89 | |
90 | |
91 global ext_flash_byte_read ; Return data read in WREG | |
92 ext_flash_byte_read: | |
93 movlw 0x03 ; Read command | |
94 rcall write_spi | |
95 rcall ext_flash_write_address ; Write 24bit address ext_flash_address:3 via SPI | |
96 rcall write_spi ; Dummy write to read data into WREG | |
97 bsf flash_ncs ; CS=1 | |
98 movwf temp1 | |
99 return ; Return data read in WREG and temp1 | |
100 | |
101 ext_flash_write_address: ; Write 24bit address ext_flash_address:3 via SPI | |
102 movf ext_flash_address+2,W ; 24Bit Address | |
103 rcall write_spi | |
104 movf ext_flash_address+1,W | |
105 rcall write_spi | |
106 movf ext_flash_address+0,W | |
107 bra write_spi ; And return.... | |
108 | |
109 global ext_flash_read_block_start ; Return data read in WREG | |
110 ext_flash_read_block_start: | |
111 movlw 0x03 ; Read command | |
112 rcall write_spi | |
113 rcall ext_flash_write_address ; Write 24bit address ext_flash_address:3 via SPI | |
114 rcall write_spi ; Dummy write to read data into WREG | |
115 return ; Return data read in WREG | |
116 | |
117 global ext_flash_read_block ; Return data read in WREG | |
118 ext_flash_read_block: | |
119 rcall incf_ext_flash_address_p1 ; Increase address +1 | |
120 bra write_spi1 ; Dummy write to read data into WREG and return | |
121 | |
122 global ext_flash_read_block_stop ; Return data read in WREG | |
123 ext_flash_read_block_stop: | |
124 bsf flash_ncs ; CS=1 | |
125 return ; NO data in WREG | |
126 | |
127 global write_byte_ext_flash_plus_header | |
128 write_byte_ext_flash_plus_header: ; Write from WREG and increase address after write | |
129 movwf temp1 ; store data | |
130 ; test if write is done at first byte of 4kB block | |
131 ; if yes -> delete 4kB block first | |
132 tstfsz ext_flash_address+0 ; at 0x00? | |
133 bra write_byte_ext_flash_plus_h1 ; No, normal Write | |
134 | |
135 movf ext_flash_address+1,W | |
136 andlw 0x0F ; Mask lower nibble | |
137 tstfsz WREG ; at 0x.0? | |
138 bra write_byte_ext_flash_plus_h1; No, normal Write | |
139 | |
140 ; At beginning of 4kB block -> rease first! | |
141 rcall ext_flash_erase4kB ; Erases 4kB sector @ext_flash_address:3 | |
142 write_byte_ext_flash_plus_h1: | |
143 movf temp1,W | |
144 rcall ext_flash_byte_write ; Write the byte | |
145 bra incf_ext_flash_address_p1 ; +1 and return | |
146 | |
279 | 147 global write_byte_ext_flash_plus_nocnt ; No increase of ext_flash_dive_counter:3 |
148 write_byte_ext_flash_plus_nocnt: | |
149 movwf temp1 ; store data | |
150 bra write_byte_ext_flash_plus2 | |
151 | |
278
dfac47ac2e1d
BUGFIX: There was a 1:4096 chance that a portion of a dive was not stored correctly resulting in download issues
heinrichsweikamp
parents:
275
diff
changeset
|
152 global write_byte_ext_flash_plus_nodel ; Does NOT delete 4kB Page when required |
279 | 153 write_byte_ext_flash_plus_nodel: ; Write from WREG and increase address after write with banking at 0x200000 |
154 movwf temp1 ; store data | |
278
dfac47ac2e1d
BUGFIX: There was a 1:4096 chance that a portion of a dive was not stored correctly resulting in download issues
heinrichsweikamp
parents:
275
diff
changeset
|
155 bra write_byte_ext_flash_plus1 ; Ignore possible begin of 4kB page, there have been written 0xFF already |
6 | 156 |
0 | 157 global write_byte_ext_flash_plus ; Write from WREG and increase address after write with banking at 0x200000 |
158 write_byte_ext_flash_plus: | |
159 movwf temp1 ; store data | |
160 | |
161 ; First, increase dive length counter | |
162 incf ext_flash_dive_counter+0,F | |
163 movlw .0 | |
164 addwfc ext_flash_dive_counter+1,F | |
165 addwfc ext_flash_dive_counter+2,F ; 24bit++ | |
166 | |
6 | 167 write_byte_ext_flash_plus2: |
0 | 168 ; Now test if write is done at first byte of 4kB block |
169 ; if yes -> delete 4kB block first | |
170 tstfsz ext_flash_address+0 ; at 0x00? | |
171 bra write_byte_ext_flash_plus1 ; No, normal Write | |
172 | |
173 movf ext_flash_address+1,W | |
174 andlw 0x0F ; Mask lower nibble | |
175 tstfsz WREG ; at 0x.0? | |
176 bra write_byte_ext_flash_plus1 ; No, normal Write | |
177 | |
178 ; At beginning of 4kB block -> erase first! | |
179 rcall ext_flash_erase4kB ; Erases 4kB sector @ext_flash_address:3 | |
180 write_byte_ext_flash_plus1: | |
181 movf temp1,W | |
182 rcall ext_flash_byte_write ; Write the byte | |
183 bra incf_ext_flash_address0_p1_0x20 ; +1 and roll over at 0x200000 to 0x000000 and return | |
184 | |
185 global ext_flash_byte_write ; Write from WREG | |
186 ext_flash_byte_write: | |
187 movwf temp1 ; store data byte | |
188 bsf flash_ncs ; CS=1 | |
189 movlw 0x06 ; WREN command | |
190 rcall write_spi | |
191 bsf flash_ncs ; CS=1 | |
192 movlw 0x02 ; Write command | |
193 rcall write_spi | |
194 rcall ext_flash_write_address ; Write 24bit address ext_flash_address:3 via SPI | |
195 movf temp1,W ; load data byte | |
196 rcall write_spi ; write one byte of data! | |
197 bsf flash_ncs ; CS=1 | |
198 return | |
199 | |
200 global ext_flash_disable_protection ; Disable write protection | |
201 ext_flash_disable_protection: | |
202 bsf flash_ncs ; CS=1 | |
203 movlw 0x50 ; EWSR command | |
204 rcall write_spi | |
205 bsf flash_ncs ; CS=1 | |
206 | |
207 movlw 0x01 ; WRSR command | |
208 rcall write_spi | |
209 movlw b'00000000' ; New status | |
210 rcall write_spi | |
211 bsf flash_ncs ; CS=1 | |
212 return | |
213 | |
214 global ext_flash_enable_protection | |
215 ext_flash_enable_protection: | |
216 bsf flash_ncs ; CS=1 | |
217 movlw 0x50 ; EWSR command | |
218 rcall write_spi | |
219 bsf flash_ncs ; CS=1 | |
220 | |
221 movlw 0x01 ; WRSR command | |
222 rcall write_spi | |
223 movlw b'00011100' ; New status (Write protect on) | |
224 rcall write_spi | |
225 bsf flash_ncs ; CS=1 | |
226 return | |
227 | |
228 | |
229 global ext_flash_erase4kB ; Erases 4kB sector | |
230 ext_flash_erase4kB: | |
231 bsf flash_ncs ; CS=1 | |
232 movlw 0x06 ; WREN command | |
233 rcall write_spi | |
234 bsf flash_ncs ; CS=1 | |
235 movlw 0x20 ; Sector erase command | |
236 rcall write_spi | |
237 rcall ext_flash_write_address ; Write 24bit address ext_flash_address:3 via SPI | |
238 bsf flash_ncs ; CS=1 | |
239 ; bra ext_flash_wait_write ; Wait for write... and return | |
240 ext_flash_wait_write: | |
241 WAITMS d'1' ; TBE=25ms... | |
242 movlw 0x05 ; RDSR command | |
243 rcall write_spi ; Read status | |
244 rcall write_spi ; Read status into WREG | |
245 bsf flash_ncs ; CS=1 | |
246 btfsc SSP2BUF,0 ; Write operation in process? | |
247 bra ext_flash_wait_write ; Yes, wait more.. | |
248 return | |
249 | |
250 global ext_flash_erase_logbook ; erases logbook memory (000000h -> 2FFFFFh -> 3MByte) | |
251 ext_flash_erase_logbook: | |
252 bsf flash_ncs ; CS=1 | |
253 clrf ext_flash_address+0 | |
254 clrf ext_flash_address+1 | |
255 clrf ext_flash_address+2 | |
256 | |
257 movlw d'48' | |
258 movwf temp1 ; 48*64kB=917504 Bytes | |
259 ext_flash_erase_logbook_loop: | |
260 movlw 0x06 ; WREN command | |
261 rcall write_spi | |
262 bsf flash_ncs ; CS=1 | |
263 movlw 0xD8 ; 64kB erase command | |
264 rcall write_spi | |
265 rcall ext_flash_write_address ; Write 24bit address ext_flash_address:3 via SPI | |
266 bsf flash_ncs ; CS=1 | |
267 rcall ext_flash_wait_write ; Wait for write... | |
268 | |
269 incf ext_flash_address+2,F ; 64kB ahead | |
270 decfsz temp1,F | |
271 bra ext_flash_erase_logbook_loop | |
272 return | |
273 | |
274 | |
275 write_spi: ; With data in WREG... | |
276 bcf flash_ncs ; CS | |
277 global write_spi1 | |
278 write_spi1: ; With data in WREG... | |
279 bcf SSP2STAT,WCOL ; Clear flag | |
280 movwf SSP2BUF ; Write to buffer | |
281 btfsc SSP2STAT,WCOL ; Was buffer full? | |
282 bra write_spi1 ; Yes, try again | |
283 | |
284 write_spi2: ; Wait for write command | |
285 btfss SSP2STAT, BF ; Buffer full? | |
286 bra write_spi2 ; No, wait. | |
287 movf SSP2BUF,W | |
288 return ; Returns RX data in WREG and SSP2BUF | |
289 | |
281
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
290 global fix_180_dives |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
291 fix_180_dives: ; fix dives made with the 1.80 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
292 clrf divesecs ; Here: # of dive (0-255) in TOC |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
293 fix_180_dives2: |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
294 rcall fix_load_dive_into_buffer ; Load header #divesecs into buffer:256 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
295 rcall fix_check_buffer ; Check the buffered dive |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
296 tstfsz WREG ; Dive needs fix? |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
297 rcall fix_buffered_dive ; Yes, fix and save it |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
298 decfsz divesecs,F ; All done? |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
299 bra fix_180_dives2 ; No, continue |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
300 return ; All done. |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
301 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
302 fix_buffered_dive: ; Yes, fix and save it |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
303 rcall ext_flash_disable_protection ; Disable write protection for external flash |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
304 banksel buffer |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
305 ; Set to 1.81 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
306 movlw .81 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
307 movwf buffer+.49 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
308 ; Fix wrong profile length |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
309 movlw .3 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
310 subwf buffer+.9,F |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
311 movlw d'0' |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
312 subwfb buffer+.10,F |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
313 subwfb buffer+.11,F |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
314 banksel common |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
315 ; save result into external flash again |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
316 rcall fix_set_to_toc_start |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
317 clrf lo |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
318 lfsr FSR0,buffer+0 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
319 fix_buffered_dive2: |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
320 movf POSTINC0,W |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
321 rcall write_byte_ext_flash_plus_header; Write from WREG and increase address after write |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
322 decfsz lo,F ; All done? |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
323 bra fix_buffered_dive2 ; No, continue |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
324 return |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
325 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
326 fix_check_buffer: ; Check the buffered dive |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
327 movff buffer+.48,temp1 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
328 movlw .1 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
329 cpfseq temp1 ; buffer+.48 = .1 ? |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
330 retlw .0 ; No, abort |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
331 movff buffer+.49,temp1 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
332 movlw .80 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
333 cpfseq temp1 ; buffer+.49 = .80 ? |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
334 retlw .0 ; No, abort |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
335 retlw .1 ; Yes, fix this dive |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
336 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
337 fix_load_dive_into_buffer: ; Load header #divesecs into buffer:256 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
338 rcall fix_set_to_toc_start |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
339 clrf lo |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
340 lfsr FSR0,buffer+0 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
341 fix_load_dive_into_buffer2: |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
342 rcall ext_flash_byte_read_plus ; increase address after read |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
343 movff temp1,POSTINC0 ; copy into buffer |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
344 decfsz lo,F ; All done? |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
345 bra fix_load_dive_into_buffer2 ; No, continue |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
346 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
347 fix_set_to_toc_start: |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
348 clrf ext_flash_address+0 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
349 clrf ext_flash_address+1 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
350 movlw 0x20 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
351 movwf ext_flash_address+2 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
352 movlw .16 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
353 mulwf divesecs; divesecs*16 = offset to 0x2000 (up:hi) |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
354 movf PRODL,W |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
355 addwf ext_flash_address+1,F |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
356 movf PRODH,W |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
357 addwfc ext_flash_address+2,F |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
358 ; pointer at the first 0xFA of header |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
359 return |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
360 |
eb758a5b44eb
BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents:
279
diff
changeset
|
361 |
0 | 362 END |