Rev. 2.50 48 June 22, 2017 Rev. 2.50 49 June 22, 2017
HT66F20/HT66F30/HT66F40/HT66F50/HT66F60
HT66FU30/HT66FU40/HT66FU50/HT66FU60
A/D Flash MCU with EEPROM
HT66F20/HT66F30/HT66F40/HT66F50/HT66F60
HT66FU30/HT66FU40/HT66FU50/HT66FU60
A/D Flash MCU with EEPROM
Programming Considerations
CaremustbetakenthatdataisnotinadvertentlywrittentotheEEPROM.Protectioncanbe
enhancedbyensuringthattheWriteEnablebitisnormallyclearedtozerowhennotwriting.Also
theBankPointercouldbenormallyclearedtozeroasthiswouldinhibitaccesstoBank1where
theEEPROMcontrolregisterexist.Althoughcertainlynotnecessary,considerationmightbegiven
intheapplicationprogramtothecheckingofthevalidityofnewwritedatabyasimplereadback
process.WhenwritingdatatheWRbitmustbesethighimmediatelyaftertheWRENbithasbeen
sethigh,toensurethewritecycleexecutescorrectly.TheglobalinterruptbitEMIshouldalsobe
clearedbeforeawritecycleisexecutedandthenre-enabledafterthewritecyclestarts.Notethat
thedeviceshouldnotentertheIDLEorSLEEPmodeuntiltheEEPROMreadorwriteoperationis
totallycomplete.Otherwise,theEEPROMreadorwriteoperationwillfail.
Programming Examples
Reading Data from the EEPROM – Polling Mothod
MOV A,EEPROM_ADRES ;userdenedaddress
MOV EEA,A
MOV A,040H ;setupmemorypointerMP1
MOV MP1,A ;MP1pointstoEECregister
MOV A,01H ;setupBankPointer
MOV BP,A
SET IAR1.1 ;setRDENbit,enablereadoperations
SET IAR1.0 ;startReadCycle-setRDbit
BACK:
SZ IAR1.0 ;checkforreadcycleend
JMP BACK
CLR IAR1 ;disableEEPROMread/write
CLR BP
MOV A,EEDATA ;movereaddatatoregister
MOV READ_DATA,A
Writing Data to the EEPROM – Polling Mothod
MOV A,EEPROM_ADRES ;userdenedaddress
MOV EEA,A
MOV A,EEPROM_DATA ;userdeneddata
MOV EED,A
MOV A,040H ;setupmemorypointerMP1
MOV MP1,A ;MP1pointstoEECregister
MOV A,01H ;setupBankPointer
MOV BP,A
CLR EMI
SET IAR1.3 ;setWRENbit,enablewriteoperations
SET IAR1.2 ;startWriteCycle-setWRbit–executedimmediatelyafterset
;WRENbit
SET EMI
BACK:
SZ IAR1.2 ;checkforwritecycleend
JMP BACK
CLR IAR1 ;disableEEPROMread/write
CLR BP