#include "c:\miniide\hcs12.inc" org $1000 org $1500 lds #$1500 ; set up stack pointer ; **************************************************************************** ; The following function program a word in the EEPROM. Index register X ; contains the address of the EEPROM location to be programmed. Double ; accumulaltor D contains the data to be programmed. ; **************************************************************************** eeprogram movb #ACCERR+PVIOL,ESTAT ; clear error flags brclr ESTAT,CBEIF,cantPRE ; command buffer not empty std 0,x ; write data to EEPROM address movb #Program,ECMD ; write the command movb #CBEIF,ESTAT ; launch the erase and check command brclr ESTAT,ACCERR+PVIOL,EEPROK cantPRE ldab #1 ; return error code 1 rts EEPROK brclr ESTAT,CCIF,EEPROK ; wait until command is done clrb ; successful program code is 0 rts end