[an error occurred while processing this directive]
|
#include "m8515def.inc"
.def temp = r16
;Fills all EEPROM locations with zero value
eezero:
ldi temp,0 ;EEPROM fill value
;Alternate entry - fills all EEPROM locations with any value from temp
eefill:
push zl ;Save Z
push zh ;
ldi zl,low(eepromend) ;EEPROM highest address LSB
ldi zh,high(eepromend) ;EEPROM highest address MSB
eew_lp:
out eearl,zl ;Set EEPROM address LSB
out eearh,zh ;Set EEPROM address MSB
out eedr,temp ;Load EEPROM fill value to EE data reg
cli ;Disable interrupts - important!!!
sbi eecr,eemwe ;Enable EEPROM writes
sbi eecr,eewe ;
sei ;Enable interrupts
eew_rdy:
sbic eecr,eewe ;Wait until EEPROM is ready for next write
rjmp eew_rdy ;
sbiw z,1 ;Decrement EE address pointer
brcc eew_lp ;Loop until all EE is erased
cbi eecr,eemwe ;Disable further EEPROM writes
pop zh ;Restore Z
pop zl ;
ret
E-mail: info@telesys.ru