Rev. 1.71 22 April 11, 2017 Rev. 1.71 23 April 11, 2017
HT66F002/HT66F0025/HT66F003/HT66F004
Cost-Effective A/D Flash MCU with EEPROM
HT66F002/HT66F0025/HT66F003/HT66F004
Cost-Effective A/D Flash MCU with EEPROM
Theaccompanyingdiagramillustratestheaddressingdataowofthelook-uptable.
Table Program Example
Thefollowingexampleshowshowthetablepointerandtabledataisdenedandretrievedfromthe
microcontroller.ThisexampleusesrawtabledatalocatedintheProgramMemorywhichisstored
thereusingtheORGstatement.ThevalueatthisORGstatementis“300H”whichreferstothestart
addressofthelastpagewithinthe1KwordsProgramMemoryofthedevice.Thetablepointeris
setupheretohaveaninitialvalueof“06H”.Thiswillensurethattherstdatareadfromthedata
tablewillbeattheProgramMemoryaddress“306H”or6locationsafterthestartofthelastpage.
Notethatthevalueforthetablepointerisreferencedtotherstaddressofthespeciedpageifthe
“TABRD[m]”instructionisbeingused.Thehighbyteofthetabledatawhichinthiscaseisequal
tozerowillbetransferredtotheTBLHregisterautomaticallywhenthe“TABRD[m]”instructionis
executed.
BecausetheTBLHregisterisaread-onlyregisterandcannotberestored,careshouldbetaken
toensureitsprotectionifboththemainroutineandInterruptServiceRoutineusetableread
instructions.Ifusingthetablereadinstructions,theInterruptServiceRoutinesmaychangethe
valueoftheTBLHandsubsequentlycauseerrorsifusedagainbythemainroutine.Asaruleitis
recommendedthatsimultaneoususeofthetablereadinstructionsshouldbeavoided.However,in
situationswheresimultaneoususecannotbeavoided,theinterruptsshouldbedisabledpriortothe
executionofanymainroutinetable-readinstructions.Notethatalltablerelatedinstructionsrequire
twoinstructioncyclestocompletetheiroperation.
Table Read Program Example
tempreg1 db ? ; temporary register #1
tempreg2 db ? ; temporary register #2
:
:
mov a,06h ; initialise low table pointer - note that this address is referenced
mov tblp,a ; to the last page or present page
:
:
tabrd tempreg1 ; transfers value in table referenced by table pointer data at program
; memory address “306H” transferred to tempreg1 and TBLH
dec tblp ; reduce value of table pointer by one
tabrd tempreg2 ; transfers value in table referenced by table pointer data at program
; memory address “305H” transferred to tempreg2 and TBLH in this
; example the data “1AH” is transferred to tempreg1 and data “0FH” to
; register tempreg2
:
:
org 300h ; sets initial address of program memory
dc 00Ah, 00Bh, 00Ch, 00Dh, 00Eh, 00Fh, 01Ah, 01Bh
:
: