- •1 Introduction to C
- •1.1 Some Simple Programs
- •1.2 Names
- •1.3 Types and Type Declarations
- •1.4 Storage Classes, Linkage, and Scope
- •1.5 Character Constants
- •1.6 Arrays
- •1.7 Other types
- •1.8 Operators and Expressions
- •1.9 Increment and Decrement Operators
- •1.10 Precedence and Associativity
- •1.11 Program Flow and Control
- •1.12 Functions
- •1.13 Recursion
- •1.14 Summary
- •2 Advanced C Topics
- •2.1 Pointers
- •2.2 Multidimensional Arrays
- •2.3 Structures
- •2.4 More Structures
- •2.5 Input and Output
- •2.6 Memory Management
- •2.7 Miscellaneous Functions
- •2.8 Summary
- •3 What Are Microcontrollers?
- •3.1 Microcontroller Memory
- •3.3 Programming Microcontrollers
- •3.4 Coding Tips for Microcontrollers
- •4.1 Microcontroller Memory
- •4.2 Timers
- •4.4 Pulse Width Modulator System
- •4.5 Other Program Items
- •4.6 Summary
- •5.1 Header File
- •5.2 Sorting Programs
- •5.3 Data Compression
- •5.4 Timer Operations
- •5.5 Summary
- •6 Large Microcontrollers
- •6.3 A Pulse Width Modulation Program
- •6.4 Cosmic MC68HC16 Compiler
- •6.6 Digital Signal Processor Operations
- •6.7 Other MC68HC16 Considerations
- •7.1 Numeric Encoding
- •7.2 Numeric Decoding
- •7.3 Coding the alpha data
- •7.4 The Monitor Program
- •7.5 The SAVEIT() Routine
- •7.6 The printout() and the printafter() Functions
- •7.7 Reset
- •7.9 Putting It All Together
- •7.10 Summary
- •8 MCORE, a RISC Machine
- •8.1 Delay Routine
- •8.2 Delays Revisited
- •8.4 Handling Interrupts
- •8.5 A Clock Program
- •8.6 Keyboard
- •8.7 Integrating Keyboard and Clock
- •8.8 Adding a Display
- •8.9 Summary
Summary 391
board. Loading the code into this board requires the use of another development board, an HC12 FLASH PROGRAMMER. This board contains an M68EVB912B32 board also. The code is downloaded into the programmer board and from there it is transferred to the FLASH memory on the second evaluation board. This combination worked to program the FLASH, and it must be noted that the final program worked as designed after one error was corrected.
Summary
In writing this chapter, I have attempted to show that modular development of a program can yield very satisfying results. The program here was reduced to several relatively small functions that could each be developed and tested separately. Then these functions were integrated one-by-one to build the whole program. This is not to say that this approach is less work. Several of the modules listed above are very complicated and require careful design to make certain that they work as desired. Some of these modules require almost invention. For example, the means used to express the Huffman table in the decode routine needed several different starts before a satisfactory one was found. Recall that the complete binary tree needed to express a Huffman code requires 2n–1 nodes where n is the number of items being encoded. I felt that it was desirable to express this tree by an array with no more than 2n–1 members. The array shown in Listing 7-7 contains exactly 2n–1 bytes. It took six different tries to arrive at this particular representation, and hence the code to decode the data.
The reward was that the final code worked in the embedded product with almost no error.