#include "c:\miniide\hcs12.inc" org $1000 org $1500 lds #$1500 ; set up stack pointer ; ******************************************************************************** ; The following routine erase an EEPROM sector pointed to by X. ; ******************************************************************************** eraseEEsector movb #ACCERR+PVIOL,ESTAT ; clear error flags brclr ESTAT,CBEIF,EERErr ; command buffer not empty, return std 0,X ; write any data to EEPROM sector movb #SectorErase,ECMD ; write sector erase command movb #CBEIF,ESTAT ; launch erase command brclr ESTAT,ACCERR+PVIOL,EEROK ; no error? EERErr ldab #1 ; error code set to 1 rts EEROK brclr ESTAT,CCIF,EEROK ; wait until command completion clrb rts