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
Reading Data from the EEPROM
ToreaddatafromtheEEPROM,thereadenablebit,RDEN,intheEECregistermustrstbeset
hightoenablethereadfunction.TheEEPROMaddressofthedatatobereadmustthenbeplaced
intheEEAregister.IftheRDbitintheEECregisterisnowsethigh,areadcyclewillbeinitiated.
SettingtheRDbithighwillnotinitiateareadoperationiftheRDENbithasnotbeenset.When
thereadcycleterminates,theRDbitwillbeautomaticallyclearedtozero,afterwhichthedatacan
bereadfromtheEEDregister.ThedatawillremainintheEEDregisteruntilanotherreadorwrite
operationisexecuted.TheapplicationprogramcanpolltheRDbittodeterminewhenthedatais
validforreading.
Writing Data to the EEPROM
TheEEPROMaddressofthedatatobewrittenmustrstbeplacedintheEEAregisterandthedata
placedintheEEDregister.TowritedatatotheEEPROM,thewriteenablebit,WREN,intheEEC
registermustrstbesethightoenablethewritefunction.Afterthis,theWRbitintheEECregister
mustbeimmediatelysethightoinitiateawritecycle.Thesetwoinstructionsmustbeexecuted
consecutively.TheglobalinterruptbitEMIshouldalsorstbeclearedbeforeimplementingany
writeoperations,andthensetagainafterthewritecyclehasstarted.SettingtheWRbithighwillnot
initiateawritecycleiftheWRENbithasnotbeenset.AstheEEPROMwritecycleiscontrolled
usinganinternaltimerwhoseoperationisasynchronoustomicrocontrollersystemclock,acertain
timewillelapsebeforethedatawillhavebeenwrittenintotheEEPROM.Detectingwhenthewrite
cyclehasnishedcanbeimplementedeitherbypollingtheWRbitintheEECregisterorbyusing
theEEPROMinterrupt.Whenthewritecycleterminates,theWRbitwillbeautomaticallycleared
tozerobythemicrocontroller,informingtheuserthatthedatahasbeenwrittentotheEEPROM.
TheapplicationprogramcanthereforepolltheWRbittodeterminewhenthewritecyclehasended.
Write Protection
Protectionagainstinadvertentwriteoperationisprovidedinseveralways.Afterthedeviceis
powered-ontheWriteEnablebitinthecontrolregisterwillbeclearedpreventinganywrite
operations.Alsoatpower-ontheBankPointer,BP,willberesettozero,whichmeansthatData
MemoryBank0willbeselected.AstheEEPROMcontrolregisterislocatedinBank1,thisaddsa
furthermeasureofprotectionagainstspuriouswriteoperations.Duringnormalprogramoperation,
ensuringthattheWriteEnablebitinthecontrolregisterisclearedwillsafeguardagainstincorrect
writeoperations.
EEPROM Interrupt
TheEEPROMwriteorreadinterruptisgeneratedwhenanEEPROMwriteorreadcyclehas
ended.TheEEPROMinterruptmustrstbeenabledbysettingtheDEEbitintherelevantinterrupt
register.HoweverastheEEPROMiscontainedwithinaMulti-functionInterrupt,theassociated
multi-functioninterruptenablebitmustalsobeset.WhenanEEPROMwritecycleends,the
DEFrequestflaganditsassociatedmulti-functioninterruptrequestflagwillbothbeset.Ifthe
global,EEPROMandMulti-function interruptsareenabledandthestackisnotfull,ajumpto
theassociatedMulti-functionInterruptvectorwilltakeplace.Whentheinterruptisservicedonly
theMulti-functioninterruptagwillbeautomaticallyreset,theEEPROMinterruptagmustbe
manuallyresetbytheapplicationprogram.MoredetailscanbeobtainedintheInterruptsection.