
HT82B60R
Rev. 1.10 9 February 1, 2011
·Table location
Any location in the program memory can be used as
look-up tables. There are three methods to read the
Program Memory data using two table read instruc-
tions: ²TABRDC²and ²TABRDL², transfer the con-
tents of the lower-order byte to the specified data
memory, and the higher-order byte to TBLH.
The three methods are shown as follows:
¨Using the instruction ²TABRDC [m]²for the current
Program Memory page, where one page=
256words, where the table location is defined by
TBLP in the current page. This is where the config-
uration option has disabled the TBHP register.
¨Using the instruction ²TABRDC [m]², where the ta-
ble location is defined by registers TBLP and TBHP.
Here the configuration option has enabled the
TBHP register.
¨Using the instruction ²TABRDL [m]², where the ta-
ble location is defined by registers TBLP in the last
page which has the address range 1F00H~
1FFFFH.
Only the destination of the lower-order byte in the ta-
ble is well-defined, the other bits of the table word are
transferred to the lower portion of TBLH, and the re-
maining 1-bit words are read as ²0². The Table
Higher-order byte register (TBLH) is read only. The ta-
ble pointers, TBLP and TBHP, are read/write regis-
ters, which indicate the table location. Before
accessing the the table, the locations must be placed
in the TBLP and TBHP registers (if the configuration
option has disabled TBHP then the value in TBHP has
no effect). TBLH is read only and cannot be restored.
If the main routine and the ISR (Interrupt Service Rou-
tine) both employ the table read instruction, the con-
tents of the TBLH in the main routine are likely to be
changed by the table read instruction used in the ISR
and errors can occur. Using the table read instruction
in the main routine and the ISR simultaneously should
be avoided. However, if the table read instruction has
to be applied in both the main routine and the ISR, the
interrupt should be disabled prior to the table read in-
struction. It will not be enabled until the TBLH has
been backed up. All table related instructions require
two cycles to complete the operation. These areas
may function as normal program memory depending
on the requirements.
Once TBHP is enabled, the instruction ²TABRDC [m]²
reads the Program Memory data as defined by the
TBLP and TBHP values. If the Program Memory code
option has disabled TBHP, the instruction ²TABRDC
[m]²reads the Program Memory data as defined by
TBLP only in the current Program Memory page.
Look-up Table
Any location within the Program Memory can be defined
as a look-up table where programmers can store fixed
data. To use the look-up table, the table pointer must
first be setup by placing the lower order address of the
look up data to be retrieved in the TBLP register and the
higher order address in the TBHP register. These two
registers define the full address of the look-up table.
Using the TBHP must be selected by configuration op-
tion, if not used table data can still be accessed but only
the lower byte address in the current page or last page
can be defined.
After setting up the table pointers, the table data can be
retrieved from the current Program Memory page or last
Program Memory page using the ²TABRDC[m]²or
²TABRDL [m]²instructions, respectively. When these in-
structions are executed, the lower order table byte from
the Program Memory will be transferred to the user de-
fined Data Memory register [m] as specified in the in-
struction. The higher order table data byte from the
Program Memory will be transferred to the TBLH special
register. Any unused bits in this transferred higher order
byte will be read as ²0².
Table Program Example
The following example shows how the table pointer and
table data is defined and retrieved from the
microcontroller. This example uses raw table data lo-
cated in the last page which is stored there using the
ORG statement. The value at this ORG statement is
²1F00H²which refers to the start address of the last
page within the 8K Program Memory of device. The ta-
ble pointer is setup here to have an initial value of ²06H².
This will ensure that the first data read from the data ta-
ble will be at the Program Memory address ²1F06H²or 6
locations after the start of the last page. Note that the
value for the table pointer is referenced to the first ad-
dress of the present page if the ²TABRDC [m]²instruc-
tion is being used. The high byte of the table data which
in this case is equal to zero will be transferred to the
TBLH register automatically when the ²TABRDL [m]²in-
struction is executed.
P r o g r a m
M e m o r y
P r o g r a m C o n t e r
H i g h B y t e
T B L P
T B L H S p e c i f i e d b y [ m ]
T a b l e C o n t e n t s H i g h B y t e T a b l e C o n t e n t s L o w B y t e
Table Read -TBLP only
P r o g r a m
M e m o r y
T B L H S p e c i f i e d b y [ m ]
H i g h B y t e o f T a b l e C o n t e n t s L o w B y t e o f T a b l e C o n t e n t s
T B L P
T B H P
Table Read -TBLP/TBHP