sbiw
ZEB<=256
brne
loophi:looplo, 1
Rdloop
;use
subi
for
PAGESI-
;
;
return to RWW section
verify that RWW section is safe to read
Return:
in
sbrs
temp1, SPMCSR
temp1, RWWSB
;
If RWWSB is set, the RWW
section is not ready yet
ret
;
ldi
rcall
rjmp
re-enable the RWW section
spmcrval, (1<<RWWSRE) | (1<<SELFPRGEN)
Do_spm
Return
Do_spm:
;
check for previous SPM complete
Wait_spm:
in
sbrc
temp1, SPMCSR
temp1, SELFPRGEN
Wait_spm
rjmp
;
;
in
cli
;
input: spmcrval determines SPM action
disable interrupts if enabled, store status
temp2, SREG
check that no EEPROM write access is present
Wait_ee:
sbic
rjmp
EECR, EEPE
Wait_ee
;
SPM timed sequence
SPMCSR, spmcrval
out
spm
;
out
ret
restore SREG (to enable interrupts if originally enabled)
SREG, temp2
254
ATmega48/88/168
2545D–AVR–07/04