Page 365 - Programming Microcontrollers in C
P. 365
350 Chapter 7 Advanced Topics
previous paragraphs. The main difference is that the development
flow will be for a DOS-based system and the microcontroller-based
code will be very carefully designed and tested and integrated into
the program as it is developed. The final tests after the code has been
transferred to the target system will be limited to those items that are
specific to the target system only.
Let us look now at what we would like our phone book code to
do.
The purpose of the program is to allow storage of names and
telephone numbers in the EEPROM section of an M68HC912B32.
This chip has 768 bytes of EEPROM and 32K bytes of FLASH
EEPROM. It has an on-board UART through which all of the
communications with the chip are conducted. One of four single-
letter commands can be entered into the system:
Command Response
n Receive a NAME terminated by an <enter>
followed by a phone number also terminated by
an <enter>.
s Display the entire directory contents.
a Display the next directory entry.
r Delete the entire contents of the directory.
Nonvolatile storage is at a premium. Therefore, all data stored in
EEPROM will be encoded to compress the data as much as practical.
All numbers will be stored in BCD form. This approach requires 4
bits per stored number when, in fact, 3.32 bits per digit is required if
it is assumed that the use of each number is equally likely. Confusion
can result when an empty number is stored, so the value stored for
the number 0 will be 0xa rather than 0x0.
Alpha, or letter, data will be compressed using a Huffman code
as was shown in Chapter 5. This code will be written specifically to
compress data from the names found in a telephone directory. Fre
quency of letter usage here is different from that found with general
English text. The decode scheme to be used here will follow the
general approach given in Chapter 5.
As a first estimate, the following functions will be required in
putting this program together: