AnsweredAssumed Answered

AW60 EEPROM Emulation in assembler

Question asked by mylim on Mar 15, 2008
Latest reply on May 18, 2008 by bigmac
Hi, I've seen a lot of EEPROM emulation example in C. I'm trying to do it in assembler.
I'm currently using CodeWarrior 6.0 on MS Windows Vista platform & the MCU i am using is AW60.
I'm trying to write the flash emulation routine above based on the flow chart show on MC9S08AW60 reference manual page 53. I've attached my code as below.
 
Code:
BLANKCHK    equ    $05BYTEPG      equ    $20BYTEBURSTPG equ    $25PAGEERASE   equ    $40MASSERASE   equ    $41;OK          equ    $00;ERR         equ    $01FADDR       equ    $8000CARDADR     ds     1FLCMD       ds     1 ;--------------------;Flash Erase/Program;--------------------;acca = adr; accx = cmdflash       psha            pshx            brclr  FSTAT_FACCERR,FSTAT,flash1       ;FACCERR = 0—            bset   FSTAT_FACCERR,FSTAT              ;clr errorflash1      bset   FSTAT_FCBEF,FSTAT                ;set FCBEF            lda    CARDADR                          ;load buffer adr & data            sta    FADDR             ldx    FLCMD                            ;write cmd to FCMD            sta    FCMD             nop                                     ;wait 7 cycle            nop            nop            nop            nop            nop            nop            bset   FSTAT_FCBEF,FSTAT                ;set FCBEF             nop                                     ;wait 7 cycle            nop            nop            nop            nop            nop            nop            brset  FSTAT_FACCERR,FSTAT,flashend     ;if FPVIOL = 1 –            brset  FSTAT_FPVIOL,FSTAT,flashend      ;if FACCERR = 1 ˜            feed_watchdog            brclr  FSTAT_FCCF,FSTAT,*               ;if FCCF = 0 ™                      flashend    pulx            pula            rts

 

Could you please advise on my code?
Thanks.
 
Regards,
MY

Outcomes