Page 260 - Programming Microcontrollers in C
P. 260
Timer Operations 245
2. Do an analysis of a substantial piece of writing and create a Huffman
code that will encode the data efficiently. It is recommended that
the first three pages of a novel be used for this analysis. Compute
the average number of bits per character that this code generates.
Hint: you might want to write a program in C for the host com
puter to calculate the histogram and help create the Huffman codes.
3. Write a program that will implement the above code so that an
operator can type the data into a computer and the Huffman code
sequences will be generated. You should break the message se
quences into moderate size bit strings, 500 to 1000 bits, and restart.
4. Create a Huffman tree table as was used in Listing 5-1 to decode
the Huffman code developed in Exercise 2.
5. How can you double the number of entries in a Huffman tree by
adding only one bit to the code strings?
Timer Operations
The programs written in the earlier sections on sorting and data
compression were more computer programs than microcontroller
programs. The code written would work on a desktop system or a
mainframe computer if needed. In this section, we graduate to true
microcontroller programming. The set up of the MC68HC11 family
requires that the programmer have a detailed knowledge of the operation
of the device. Even though the program is written in a high-level
language, it is the responsibility of the programmer to properly set all
of the necessary control bits to make the device work as desired.
Unfortunately, there are few helpful tools that can guide you through
this portion of the program. You must first understand what you want
the device to do and then dig through its specifications to find the
necessary bits to be set to make it perform as desired. It is highly
recommended that prior to an attempt at programming this device that
you familiarize yourself with the technical data manual for it as well
as the reference manual for the family that is found on the CD-ROM.
The timer subsystem in the MC68HC11 family contains both
input capture operations and output compare functions. In this section,
we will explore these subsystems associated with the MC68HC11Ex
series. The main difference between the Ex series and the other devices
lies in the number of output compare and input capture systems on