Table Example 3: 8-Bit Independent Variable - Motorola MC68340 User Manual

Integrated processor with dma
Hide thumbs Also See for MC68340:
Table of Contents

Advertisement

Since the table is reduced from 257 to 5 entries, independent variable X must be scaled
appropriately. In this case the scaling factor is 64, and the scaling is done by a single
instruction:
Thus, Dx now contains the following bit pattern:
31
NOT USED
Using this information, the table instruction calculates dependent variable Y:
The function chosen for Examples 1 and 2 is linear between data points. If another
function had been been used, interpolated values might not have been identical.
5.3.4.3 TABLE EXAMPLE 3: 8-BIT INDEPENDENT VARIABLE. This example shows
how to use a table instruction within an interpolation subroutine. Independent variable X is
calculated as an 8-bit value, allowing 16 levels of interpolation on a 17-entry table. X is
passed to the subroutine, which returns an 8-bit result. The subroutine uses the data listed
in Table 5-15, based on the function shown in Figure 5-9.
5-32
Freescale Semiconductor, Inc.
Table 5-14. Compressed Table Entries
Entry Number
X Value
2
512
3
786
LSR.W #6,Dx
16
Table Entry Offset
Interpolation Fraction
Y = 1331
(142 (1966 – 1311)) / 256 = 1674
MC68340 USER'S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Y Value
1311
1966
15
0
0
0
0
0
0
1
0
Dx [8:15] = $02 = 2
Dx [0:7] = $8E = 142
0
1
0
0
0
1
1
1
0
MOTOROLA

Advertisement

Table of Contents
loading

Table of Contents