Rev. 1.50 38 August 28, 2017 Rev. 1.50 39 August 28, 2017
HT66F0175/HT66F0185
A/D Flash MCU with EEPROM
HT66F0175/HT66F0185
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
TowritedatatotheEEPROM,theEEPROMaddressofthedatatobewrittenmustrstbeplaced
intheEEAregisterandthedataplacedintheEEDregister.Thenthewriteenablebit,WREN,
intheEECregistermustfirstbesethightoenablethewritefunction.Afterthis,theWRbitin
theEECregistermustbeimmediatelysethightoinitiateawritecycle.Thesetwoinstructions
mustbeexecutedconsecutively.TheglobalinterruptbitEMIshouldalsofirstbeclearedbefore
implementinganywriteoperations,andthensetagainafterthewritecyclehasstarted.Notethat
settingtheWRbithighwillnotinitiateawritecycleiftheWRENbithasnotbeenset.Asthe
EEPROMwritecycleiscontrolledusinganinternaltimerwhoseoperationisasynchronousto
microcontrollersystemclock,acertaintimewillelapsebeforethedatawillhavebeenwritteninto
theEEPROM.Detectingwhenthewritecyclehasnishedcanbeimplementedeitherbypollingthe
WRbitintheEECregisterorbyusingtheEEPROMinterrupt.Whenthewritecycleterminates,
theWRbitwillbeautomaticallyclearedtozerobythemicrocontroller,informingtheuserthatthe
datahasbeenwrittentotheEEPROM.TheapplicationprogramcanthereforepolltheWRbitto
determinewhenthewritecyclehasended.
Write Protection
Protectionagainstinadvertentwriteoperationisprovidedinseveralways.Afterthedeviceis
poweredon,theWriteEnablebitinthecontrolregisterwillbeclearedpreventinganywrite
operations.Alsoatpower-ontheBankPointerregister,BP,willberesettozero,whichmeansthat
DataMemorybank0willbeselected.AstheEEPROMcontrolregisterislocatedinbank1,this
addsafurthermeasureofprotectionagainstspuriouswriteoperations.Duringnormalprogram
operation,ensuringthattheWriteEnablebitinthecontrolregisterisclearedwillsafeguardagainst
incorrectwriteoperations.
EEPROM Interrupt
TheEEPROMwriteinterruptisgeneratedwhenanEEPROMwritecyclehasended.TheEEPROM
interruptmustrstbeenabledbysettingtheDEEbitintherelevantinterruptregister.However,as
theEEPROMiscontainedwithinaMulti-functionInterrupt,theassociatedmulti-functioninterrupt
enablebitmustalsobeset.WhenanEEPROMwritecycleends,theDEFrequestflagandits
associatedmulti-functioninterruptrequestagwillbothbeset.Iftheglobal,EEPROMandMulti-
functioninterruptsareenabledandthestackisnotfull,ajumptotheassociatedMulti-function
Interruptvectorwilltakeplace.WhentheinterruptisservicedonlytheMulti-functioninterruptag
willbeautomaticallyreset,theEEPROMinterruptagmustbemanuallyresetbytheapplication
program.