#include "c:\miniide\hcs12.inc" org $1000 org $1500 lds #$1500 ; set up stack pointer ; ******************************************************************************** ; The following routine erases the whole EEPROM. Index register X points to any ; word aligned EEPROM location. ; ******************************************************************************** bulkeraseEE movb #ACCERR+PVIOL,ESTAT ; clear error flags brclr ESTAT,CBEIF,EEBEErr ; command buffer not empty, return std 0,X ; write any data to EEPROM movb #BulkErase,ECMD ; write bulk erase command movb #CBEIF,ESTAT ; launch bulk erase command brclr ESTAT,ACCERR+PVIOL,EEBROK ; no error? EEBEErr ldab #1 ; error code set to 1 rts EEBROK brclr ESTAT,CCIF,EEBROK ; wait until command completion clrb rts