Hi. I'm a beginner of Freescale 8-Bit MCU. Recent I read the code below used to erase the EEPROM of DZ60. I have understood most of code means. But I cannot understand first three line of codes. Should someone like to explain these for me? Thanks!
E_EEPROM:
STA ,X ; H:X中是要擦出的EEPROM段的地址
NOP
STA ,X lda #(mFSTAT_FPVIOL + mFSTAT_FACCERR)
sta FSTAT sta 0, x ; H:X中保存着要擦出的EEPROM的地址
lda #mFSTAT_FCBEF
sta FSTAT
nop
CheckDoneEErase:
lda FSTAT
lsla bpl CheckDoneEErase
aix #8
cphx #EEP_END
blo E_EEPROM
jmp SUCC
Hello,
I assume that you refer to the following lines -
STA ,X NOP STA ,X
This sequence writes the accumulator value directly to the address pointed to by the H:X register, twice. I am unable to read the Chinese characters in the original comment, but would assume that H:X value represents an address within the flash sector to be erased.
The purpose of writing the value twice escapes me - this does not seem to be a specific requirement of the erase process.
Regards,
Mac
Hello, bigmac. Thanks for your replying. I'm sorry to say that my English is not good, and assembly language of HCS08 is little hard to me. Maybe I should remove these three lines of code to see if there is some effect to erase process.
祝好,
刘宇
Hello 刘宇,
Do not remove all three lines - at least one write is needed, otherwise the erase will not work.
Regards,
Mac
Hello Bigmac
Thanks for your advise. I guess you mean that STA , X is necessary because we should write any byte to the address in the EEPROM where need to erase. But I think the fifth line of code realize the purpose.
sta FSTAT sta 0, x ; H:X中保存着要擦出的EEPROM的地址
Anyway, let me try to see the effect of removing those code.
Thanks Mac and a good weekend!
刘宇