;**************************************************************************
**
flash_prg_page:
RCALL WAIT_SPMEN ;Wait for SPMEN flag cleared
MOV
R31,R17
MOV
R30,R16
;move adress to z pointer (R31=ZH R30=ZL)
OUT
RAMPZ, R18
LDI
R20,$05
;(1<<PGWRT) + (1<<SPMEN))
OUT SPMCSR,R20; argument 2 decides function (r18)
SPM
;Store program memory
RCALL WAIT_SPMEN ;Wait for SPMEN flag cleared
RCALL flash_rww_enable
RET
;*F************************************************************************
**
; NAME: flash_page_erase
;--------------------------------------------------------------------------
--
; PARAMS: R18:17:R16: The byte address of the page
;--------------------------------------------------------------------------
--
; PURPOSE: Launch the erase sequence of the target page
;--------------------------------------------------------------------------
--
; NOTE: This function does nt set the RWWSE bit after erase. Thus it does
not
; erase the hardware temporary temp buffer.
; This function is for bootloader usage
;--------------------------------------------------------------------------
--
; REQUIREMENTS:
;**************************************************************************
**
flash_page_erase:
RCALL WAIT_SPMEN ;Wait for SPMEN flag cleared
MOV
R31,R17
MOV
R30,R16
;move adress to z pointer (R31=ZH R30=ZL)
OUT
RAMPZ, R18
LDI
R20,$03
;(1<<PGERS) + (1<<SPMEN)))
OUT SPMCSR, R20; argument 2 decides function (r18)
SPM
;Store program memory
RCALL WAIT_SPMEN ;Wait for SPMEN flag cleared
;RCALL flash_rww_enable CAUTION DO NOT ACTIVATE HERE or
;
you will loose the entire page buffer content !!!
RET
22
7618C–AVR–07/08