200 likes | 427 Views
EEPROM -- 9S12DP256. EETS4K Block Guide. EEPROM. MC12S-DP256 4 Kbytes of EEPROM $0400 - $0FFF $FEC – FFF used for autostart in CML 12S-DP256. ; STORE WORD D AT ADDRESS Y AND Y+1 EESTD TST ESTAT BPL EED3 STD 0,Y LDAA #$20 ;program word STAA ECMD
E N D
EEPROM-- 9S12DP256 EETS4K Block Guide
EEPROM • MC12S-DP256 • 4 Kbytes of EEPROM • $0400 - $0FFF • $FEC – FFF used for autostart in CML 12S-DP256
; STORE WORD D AT ADDRESS Y AND Y+1 EESTD TST ESTAT BPL EED3 STD 0,Y LDAA #$20 ;program word STAA ECMD LDAA #$80 STAA ESTAT ;launch the command LDAA ESTAT BITA #$20 ;test PVIOL BNE EED1 LDAA #$20 STAA ESTAT ;clear PVIOL BRA EED3 EED1 BITA #$10 ;test ACCERR BNE EED2 LDAA #$10 STAA ESTAT ;clear ACCERR BRA EED3 EED2 LDAA ESTAT ;wait for command to finish BPL EED2 EED3 RTS
; ERASE 2 WORDS AT ADDRESS Y to Y+3 ERASE TST ESTAT BPL ERS3 LDD #0 STD 0,Y ;address in sector LDAA #$40 ;erase sector STAA ECMD LDAA #$80 STAA ESTAT ;launch the command LDAA ESTAT BITA #$20 ;test PVIOL BNE ERS1 LDAA #$20 STAA ESTAT ;clear PVIOL BRA ERS3 ERS1 BITA #$10 ;test ACCERR BNE ERS2 LDAA #$10 STAA ESTAT ;clear ACCERR BRA ERS3 ERS2 LDAA ESTAT ;wait for command to finish BPL ERS2 ERS3 RTS
; EE! ( n addr -- ) EEST LDY 2,X+ LDD 0,Y CPD #$FFFF ;if not FFFF BEQ EES1 JSR ERASE ;erase sector EES1 LDD 2,X+ JSR EESTD ;program D RTS
; ERASE.BULK ( -- ) BULKE TST ESTAT BPL ERB3 LDD #0 STD EESTART ;write anything to EEPROM LDAA #$41 ;erase bulk STAA ECMD LDAA #$80 STAA ESTAT ;launch the command LDAA ESTAT BITA #$20 ;test PVIOL BNE ERB1 LDAA #$20 STAA ESTAT ;clear PVIOL BRA ERB3 ERB1 BITA #$10 ;test ACCERR BNE ERB2 LDAA #$10 STAA ESTAT ;clear ACCERR BRA ERB3 ERB2 LDAA ESTAT ;wait for command to finish BPL ERB2 ERB3 RTS