Mercurial > public > hwos_code
comparison src/external_flash.asm @ 420:789230298511
fix handling for new flash memory chip
author | heinrichsweikamp |
---|---|
date | Fri, 29 Apr 2016 15:38:57 +0200 |
parents | 4389fe9673b2 |
children | 3895adc3477f |
comparison
equal
deleted
inserted
replaced
419:881399cf0f5b | 420:789230298511 |
---|---|
64 btfss ext_flash_address+2,7 ; Rollover to 0xFFFFFF? | 64 btfss ext_flash_address+2,7 ; Rollover to 0xFFFFFF? |
65 return ; No, return | 65 return ; No, return |
66 clrf ext_flash_address+2 ; Set to 0x00FFFFF | 66 clrf ext_flash_address+2 ; Set to 0x00FFFFF |
67 setf ext_flash_address+1 | 67 setf ext_flash_address+1 |
68 setf ext_flash_address+0 | 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 | 69 return |
77 | 70 |
78 global ext_flash_byte_read_plus ; Return data read in WREG and SSP2BUF and | 71 global ext_flash_byte_read_plus ; Return data read in WREG and SSP2BUF and |
79 ext_flash_byte_read_plus: ; increase address after read | 72 ext_flash_byte_read_plus: ; increase address after read |
80 rcall ext_flash_byte_read | 73 rcall ext_flash_byte_read |
189 movlw 0x06 ; WREN command | 182 movlw 0x06 ; WREN command |
190 rcall write_spi | 183 rcall write_spi |
191 bsf flash_ncs ; CS=1 | 184 bsf flash_ncs ; CS=1 |
192 movlw 0x02 ; Write command | 185 movlw 0x02 ; Write command |
193 rcall write_spi | 186 rcall write_spi |
194 rcall ext_flash_write_address ; Write 24bit address ext_flash_address:3 via SPI | 187 rcall ext_flash_write_address ; Write 24bit address ext_flash_address:3 via SPI |
195 movf temp1,W ; load data byte | 188 movf temp1,W ; load data byte |
196 rcall write_spi ; write one byte of data! | 189 rcall write_spi ; write one byte of data! |
197 bsf flash_ncs ; CS=1 | 190 bsf flash_ncs ; CS=1 |
198 return | 191 return |
199 | 192 |
211 rcall write_spi | 204 rcall write_spi |
212 bsf flash_ncs ; CS=1 | 205 bsf flash_ncs ; CS=1 |
213 | 206 |
214 ; unlock new memory | 207 ; unlock new memory |
215 ; bsf flash_ncs ; CS=1 | 208 ; bsf flash_ncs ; CS=1 |
209 ; movlw 0x06 ; WREN command | |
210 ; rcall write_spi | |
211 ; bsf flash_ncs ; CS=1 | |
212 ; movlw 0x98 ; ULBPR command | |
213 ; rcall write_spi | |
214 ; bsf flash_ncs ; CS=1 | |
215 | |
216 ;bsf flash_ncs ; CS=1 | |
216 movlw 0x06 ; WREN command | 217 movlw 0x06 ; WREN command |
217 rcall write_spi | 218 rcall write_spi |
218 bsf flash_ncs ; CS=1 | 219 bsf flash_ncs ; CS=1 |
219 movlw 0x98 ; ULBPR command | 220 movlw 0x42 ; WBPR command |
220 rcall write_spi | 221 rcall write_spi |
221 bsf flash_ncs ; CS=1 | 222 movlw .18 |
223 movwf temp1 | |
224 ext_flash_disable_protection2: | |
225 movlw 0x00 | |
226 rcall write_spi | |
227 decfsz temp1,F ; 18 bytes with 0x00 | |
228 bra ext_flash_disable_protection2 | |
229 bsf flash_ncs ; CS=1 | |
222 return | 230 return |
223 | 231 |
224 global ext_flash_enable_protection | 232 global ext_flash_enable_protection |
225 ext_flash_enable_protection: | 233 ext_flash_enable_protection: |
226 ; lock old memory | 234 ; lock old memory |