diff options
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/bootloader.asm | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm index dc7d119..f8b609c 100644 --- a/bootloader/bootloader.asm +++ b/bootloader/bootloader.asm @@ -37,7 +37,7 @@ VERSION_MAJ EQU .0 VERSION_MIN EQU .1 DEVID_H EQU H'20' DEVID_L EQU H'82' -FSS EQU .8 +FSS EQU .16 MESS_H EQU .0 MESS_L EQU .64 SUPPORTED_H EQU .0 @@ -348,7 +348,7 @@ cmd_w_config ;; actual flash/eeprom functions ;; flash read -------- read_flash_segment - movlw FSS + movlw FSS ; initialize EEADR:EEADRH and FSR movwf cnt1 movlw b'01011000' movwf STATUS @@ -360,19 +360,19 @@ read_flash_segment movf INDF,w movwf EEADRH read_flash_segment_loop - bsf STATUS,RP0 + bsf STATUS,RP0 ; perform the actual read bsf EECON1,EEPGD bsf EECON1,RD nop nop bcf STATUS,RP0 - movf EEDAT,w + movf EEDAT,w ; load code word from EEDAT:EEDATH to combuff movwf INDF incf FSR,f movf EEDATH,w movwf INDF incf FSR,f - incfsz EEADR,f + incfsz EEADR,f ; increment flash address goto read_flash_segment_next incf EEADRH,f read_flash_segment_next @@ -404,17 +404,8 @@ write_flash_segment_loop movf INDF,w movwf EEDATH - bsf STATUS,RP0 ; if code word is 0xFFFF, read the current value first - btfss INDF,7 ; this will leave this word unchanged - goto write_flash_segment_write - + bsf STATUS,RP0 ; now start the acutal write sequence bsf EECON1,EEPGD - bsf EECON1,RD - nop - nop - -write_flash_segment_write - bsf EECON1,EEPGD ; now start the acutal write sequence bsf EECON1,WREN movlw H'55' movwf EECON2 @@ -431,8 +422,13 @@ write_flash_segment_write write_flash_segment_next decfsz cnt1,f goto write_flash_segment_loop + bsf STATUS,RP0 + clrw + btfsc EECON1,WRERR + movlw E_FLASH_WERR bcf STATUS,RP1 - clrf combuff + .1 ; = E_OK + bcf STATUS,RP0 + movwf combuff + .1 ; = E_OK retlw .2 ; bytes to send ;; ------------------------------------- |