* Program EEPROM (6811) * Copies telephone number located at location TEL_NO to eeprom * locations beginning at $B600. Terminating character of the * tel number is $FF. * * When the terminating character is encountered, it is * copied to eeprom and the routine is exited. * Intended to illustrate how to erase and program eeprom. * Peter H. Anderson, MSU, 16 Jan 90, Checked 16 Jan 90. * revised 13 Feb 90; Checked 13 Feb 90. * revised 15 Oct 91; 15 Jan 93 PSCT EQU $C000 DSCT EQU $D000 IDSCT EQU $D300 REG_BASE EQU $1000 STACKTP EQU $0045 EEPRMTP EQU $B600 PORTC EQU $03 PORTB EQU $04 DDRC EQU $07 PPROG EQU $3B BYTE EQU $10 * bit 4 of pprog - used to id byte * * mode erase ERASE EQU $04 * bit 2 of pprog EELAT EQU $02 * bit 1 of pprog - eeprom latch EEPGM EQU $01 * bit 0 of pprog - eeprom program ORG PSCT * program section LDS #STACKTP LDY #REG_BASE LDX #EEPRMTP * intitial destination adr - eeprom STX EEP_PTR * LDX #TEL_NO * initial source adr STX TEL_PTR TOP BSR EE_ERASE * erase loc specified in EEP_PTR LDX TEL_PTR LDAA 00,X * digit now in A BSR EE_PROG * write data in A to dest specified in EEP_PTR * * X still at adr of tel digit BRSET 00,X #$FF DONE * if terminating char, exit LDX EEP_PTR * next loc in eeprom INX STX EEP_PTR LDX TEL_PTR * next telephone digit INX STX TEL_PTR BRA TOP DONE SWI EE_ERASE * subroutine EE_ERASE. Erases loc specified in EEP_PTR PSHX * save X PSHA LDX EEP_PTR * get pointer LDAA #BYTE|ERASE|EELAT * erase in byte mode STAA PPROG,Y CLR 00,X * write anything to loc LDAA #BYTE|ERASE|EELAT|EEPGM * eepgm brought to 1 STAA PPROG,Y BSR DELAY_10 * hold it for 10 msecs CLR PPROG,Y * clear the ctrl reg PULA PULX RTS EE_PROG * subroutine EE_PROG. Writes content of acca to loc specified in EEP_PTR PSHX PSHB LDX EEP_PTR * get EE ptr LDAB #EELAT * select eeprom STAB PPROG,Y STAA 00,X * write A to loc X LDAB #EELAT|EEPGM *eepgm brought high STAB PPROG,Y BSR DELAY_10 * hold for 10 mecs CLR PPROG,Y * clear the control reg PULB PULX RTS DELAY_10 PSHX LDX #3333 * 3333dec * 6 = 19,998 ~ L1 DEX * 20,000 * 0.5 usecs = 10 msecs BNE L1 PULX RTS ORG DSCT * data section TEL_PTR RMB 2 * adr of tel number digits EEP_PTR RMB 2 * adr of eeprom ORG IDSCT * initialized data section TEL_NO FCB $01,$0A,$03,$00,$01 * 1-pause-301-444-3912 FCB $04,$04,$04 * $0A is short pause FCB $03,$09,$01,$02 FCB $FF * end of digits