Tables ease microcontroller programming
Abel Raynus, Armatron International, Malden, MA; Edited by Martin Rowe and Fran Granville -- EDN, April 22, 2010
When creating microcontroller firmware, you often need to work with data arrays. Tables make easy work of data arrays, such as those for digital-code transformation, correction for sensor linearity, sophisticated calculations, and multiple output organization. Table 1 shows how you can organize data in a table. Outputs A, B, and C have values based on the input value, V.
When using a lookup table, choose the proper microcontroller input and outputs. Assign values for input and outputs data in Table 2. These data can consist of constants in binary, hexadecimal, or decimal format or names. For names, you should assign a constant value to each one. For example:
data1 equ $0a
data2 equ $0b
data3 equ $0c
data3 equ $0d
Next, put the data from Table 2 in either the beginning or the end of ROM, which makes the data easy to find. For definition of 1-byte data storage, use pseudo operators FCB or DB. For storage of data comprising 2 bytes, use FDB or DW, as in the following example:ORG ROM
VxFCB 0T,2T,4T,6T
AxFCB data1,data2,data3,data4
BxFCB $aa,$bb,$cc,$dd
Cx FDB $1122,$3344,$5566,$7788
Note that commas separate the data. Don’t place a comma after the last data, or it will be considered as $00.
In the listing of assembler code, you can double-check the table content in memory at addresses $F800 through $F813. The listing uses Freescale assembler because most of the appropriate applications employ inexpensive, 8-bit microcontrollers from Freescale’s HC08 Nitron family. You can, however, use this approach with any type of microcontroller and assembly language.
-
This is also elementary programming practice - nothing novel here at all!
Andrew Neil - 2010-28-8 14:20:18 PDT -
I can´t see the figures.
where are the "pdf" link.
pdf files are preferable.
Nicolas Olifir - 2010-27-5 12:08:59 PDT





















