Page 301 - Programming Microcontrollers in C
P. 301
286 Chapter 5 Programming Large 8-Bit Systems
compare channel, but it does not tie up the microcontroller to wait
out any delay times during the debounce period. This program is not
too removed from many of those encountered in the real world.
The organization of the program is similar to how most
applications can be programmed, and the way in which the program
was developed showed how most problems should be approached.
The problem was broken down into a set of small operations that
could each be handled easily. These different parts of the program
were developed, tested, and debugged separately. This approach keeps
the development of the individual parts of the program manageable,
and debugging is not too difficult. If the whole program were written
and then debugging started, it would have been nearly impossible to
separate out the effects of one part of the program on the others. The
main interrupt service routines were written first and tested as well
as possible by themselves. With these important functions behind us,
it was easy to attack the applications portion of the program in which
the closed loop system was implemented along with the management
of the input/output through the serial port of the device.
The MC68HC11 is a powerful enough computer that it is possible
to make an ANSI compliant compiler. Parameters can be passed to
functions on the stack, and re-entrant or recursive functions can be
written for this part as was demonstrated with the dprint()
function. Remember, it is the microcontroller that limited the ANSI
compliance with the MC68HC05—not the compiler.