; ### Init_FLASH init code; FSTAT: FCBEF=0,FCCF=0,FPVIOL=1,FACCERR=1,FBLANK=0 LDA #%00110000 STA FSTAT ; Clear error flags; FCDIV: DIVLD=0,PRDIV8=0,DIV5=1,DIV4=0,DIV3=1,DIV2=0,DIV1=0,DIV0=1 LDA #$45 STA FCDIV ; Set clock dividerJSR waitForFlashSTA CounterStorage ; set what data address to eraseLDX #mSectorErase ; erase the sectorJSR flashCommand ; run commandflashCommand: STX FCMD ; Set the command specified in X LDX #mFSTAT_FCBEF ; loads the flash status STX FSTAT ; Load it back to the status to start the command RTSwaitForFlash: LDA FSTAT ; Load Flash Status AND #mFSTAT_FCCF ; Check for Flash Command Complete Flag BEQ waitForFlash ; If bit was 0, Z would now be set LDA FSTAT ; Load in the flash status AND #(mFSTAT_FACCERR+mFSTAT_FPVIOL) ; Check for an error BEQ waitForFlash_continue STA FSTAT ; If one exists, clear it waitForFlash_continue: RTS ; Flash is done and any error was cleared
http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S08DZ60.pdf?fsrch=1&WT_TYPE=Data%2...
On-Chip Memory
• Flash read/program/erase over full operating voltage and
temperature
— MC9S08DZ60 = 60K
— MC9S08DZ48 = 48K
— MC9S08DZ32 = 32K
— MC9S08DZ16 = 16K
• Up to 2K EEPROM in-circuit programmable memory;
8-byte single-page or 4-byte dual-page erase sector;
Program and Erase while executing Flash; Erase abort
• Up to 4K random-access memory (RAM)