Mercurial > public > hwos_code
comparison src/external_flash.asm @ 633:690c48db7b5b
3.09 beta 2 release
author | heinrichsweikamp |
---|---|
date | Thu, 05 Mar 2020 15:06:14 +0100 |
parents | 185ba2f91f59 |
children | 4050675965ea |
comparison
equal
deleted
inserted
replaced
632:0347acdf6d8e | 633:690c48db7b5b |
---|---|
172 ; write-range function, to be used through macro | 172 ; write-range function, to be used through macro |
173 ; | 173 ; |
174 global ext_flash_write_range | 174 global ext_flash_write_range |
175 ext_flash_write_range: | 175 ext_flash_write_range: |
176 movwf eeprom_loop ; load loop counter (eeprom variable used here) | 176 movwf eeprom_loop ; load loop counter (eeprom variable used here) |
177 | |
178 ; btfsc flash_block_write ; does the FLASH support block-write? | |
179 ; bra ext_flash_write_range_block ; YES - write date via block operation | |
180 ; ;bra ext_flash_write_range_seq ; NO - write data via sequential single writes | |
181 | |
182 ext_flash_write_range_seq: ; sequential write | |
183 ext_flash_write_range_loop_s: | |
184 movff POSTINC1,ext_flash_rw ; read byte from memory to ext_flash_rw | |
185 rcall ext_flash_byte_write ; write byte from ext_flash_rw to FLASH | |
186 rcall incf_ext_flash_address_p1_0x40 ; increase address with wrap-around at 0x400000 | |
187 decfsz eeprom_loop,F ; decrement loop counter, all done? | |
188 bra ext_flash_write_range_loop_s ; NO - continue loop | |
189 return ; YES - done | |
190 | |
191 ext_flash_write_range_block: ; block write | |
177 movff POSTINC1,ext_flash_rw ; read first byte from memory | 192 movff POSTINC1,ext_flash_rw ; read first byte from memory |
178 rcall ext_flash_write_block_start ; write first byte to FLASH | 193 rcall ext_flash_write_block_start ; write first byte to FLASH |
179 bra ext_flash_write_range_loop_start; jump into loop | 194 bra ext_flash_write_range_loop_start; jump into loop |
180 ext_flash_write_range_loop: | 195 ext_flash_write_range_loop_b: |
181 movff POSTINC1,ext_flash_rw ; read next byte from memory | 196 movff POSTINC1,ext_flash_rw ; read next byte from memory |
182 rcall ext_flash_write_block ; write next byte to FLASH | 197 rcall ext_flash_write_block ; write next byte to FLASH |
183 ext_flash_write_range_loop_start: | 198 ext_flash_write_range_loop_start: |
184 decfsz eeprom_loop,F ; decrement loop counter, all done? | 199 decfsz eeprom_loop,F ; decrement loop counter, all done? |
185 bra ext_flash_write_range_loop ; NO - continue loop | 200 bra ext_flash_write_range_loop_b ; NO - continue loop |
186 bra ext_flash_write_block_stop ; YES - end writing to flash (and return) | 201 bra ext_flash_write_block_stop ; YES - end writing to flash (and return) |
187 | 202 |
188 ; ---------------------------------------------------------------------------- | 203 ; ---------------------------------------------------------------------------- |
189 | 204 |
190 ; global write_byte_ext_flash_plus_header | 205 ; global write_byte_ext_flash_plus_header |
191 ; write_byte_ext_flash_plus_header: | 206 ; write_byte_ext_flash_plus_header: |
192 ; movwf ext_flash_rw ; store byte to write | 207 ; movwf ext_flash_rw ; store byte to write |
193 ; ; test if write is done at first byte of 4kB block, if yes delete 4kB block first | 208 ; ; test if write is done at first byte of 4kB block, if yes delete 4kB block first |
194 ; tstfsz ext_flash_address+0 ; at 0x....00 ? | 209 ; tstfsz ext_flash_address+0 ; at 0x....00 ? |