Christopher Barth

Problem with writing to flash MC9S08DZ60.

Discussion created by Christopher Barth on Aug 13, 2008
Latest reply on Aug 14, 2008 by Jim Donelson
This question was posed because the code runs correctly in an emulator, and also runs correctly when stepped through via the BDM. Unfortunately, when we run the code without stepping through line by line, the code errors out, with the FACCERR flag being set. I have looked through the documentation and the list of possible causes of the FACCERR flag being set, and none of seem to be occurring (at least in an obvious way). Any help you could offer would be greatly appreciated, and let me know if there are any more files you will need.

Relevent pieces of code:

; ### 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    

Added p/n to subject.

Message Edited by NLFSJ on 2008-08-14 09:25 AM