Rev. 2.50 32 June 22, 2017 Rev. 2.50 33 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
Table Program Example
Thefollowingexampleshowshowthetablepointerandtabledataisdenedandretrievedfromthe
microcontroller.ThisexampleusesrawtabledatalocatedintheProgramMemorywhichisstored
thereusingtheORGstatement.ThevalueatthisORGstatementis"700H"whichreferstothestart
addressofthelastpagewithinthe2KProgramMemoryoftheHT66F30.Thetablepointerissetup
heretohaveaninitialvalueof"06H".Thiswillensurethattherstdatareadfromthedatatablewill
beattheProgramMemoryaddress"706H"or6locationsafterthestartofthelastpage.Notethat
thevalueforthetablepointerisreferencedtotheaddressspeciedbytheTBLPandTBHPifthe
"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 byte table pointer - note that this address
; is referenced
mov tblp, a
mov a,07h ; initialise high table pointer
mov tbhp, a
:
:
tabrdl tempreg1 ; transfers value in table referenced by table pointer data at
; program memory address "706H" transferred to tempreg1 and TBLH
dec tblp ; reduce value of table pointer by one
tabrdl tempreg2 ; transfers value in table referenced by table pointer data at
; program memory address "705H" transferred to tempreg2 and TBLH in
; this example the data "1AH" is transferred to tempreg1 and data
; "0FH" to register tempreg2
:
:
org 700h ; sets initial address of program memory
dc 000Ah, 000Bh, 000Ch, 000Dh, 000Eh, 000Fh, 001Ah, 001Bh
:
: