1. Introduction – Microcontrollers and C
1.1 From Microprocessors to Microcontrollers
1.2 DRAGON12-Plus-USB-USB™ Board
1.3 The CodeWarrior Development Tools
2. Parallel Ports – Outputs
2.1 MC9S12DG256 Parallel I/O Ports
2.2 LEDs and 7-Segment Displays
Example 1 – Writing to Ports
Example 2 – C Function Calls
Example 3 – Delay Loops in C
Example 4 – Delay Loops in Assembly: ms_delay(int n)
Example 5 – Turning Single Bits On and Off
Example 6 – Hex Counter
Example 7 – Multiplexing the 7-Segment Displays
Problems
3. Parallel Ports – Inputs
3.1 Pushbuttons and DIP Switches
Example 8 – Switches on the DRAGON12-Plus-USB
3.2 Hex Keypad
Example 9 – Hex Keypad in C
Example 10 – Keypad C Function Calls Problems
Problems
4. Liquid Crystal Displays
4.1 Liquid Crystal Displays
Example 11 – Writing a Message on the LCD
4.2 Binary Number to ASCII String Conversion
Example 12 – Displaying Integers on the LCD
4.3 ASCII Number String to Binary Conversion
Example 13 – Calculator
Problems
5. Interrupts
5.1 Hardware Interrupts
5.2 Real-Time Interrupts
Example 14 – Blinking 7-Segment Display
Example 15 – Interrupt-Driven Traffic Light
Example 16 – Interrupt-Driven Blinking SOS
6. Analog-to-Digital Converter
6.1 Analog-to-Digital Conversion
6.2 Using the MC9S12DG256 A/D Converters
Example 17 – Reading the Potentiometer Value
6.3 Measuring Acceleration
Example 18 – Measuring the x-y-z Components of Acceleration
Example 19 – Measuring the Coefficient of Static Friction
6.4 Measuring Temperature
Example 20 – Displaying the Temperature on the LCD
7. Pulse-Width Modulation (PWM) – Motors and Servos
7.1 Connecting a Motor to a Microcontroller
Example 21 – Controlling the Speed of a DC Motor Using PWM
7.2 DC Servo Motors
Example 22 – Controlling the Position of a Servo Using PWM
8. Serial Communication Interface (SCI)
8.1 Asyncronous Serial I/O
8.2 The 68HCS12 SCI Interface
Example 23 – SCI Echo with LCD Display
8.3 A Circular Queue Data Structure
Example 24 – Keypad Input to LCD Using a Queue
8.4 SCI Interface Using Interrupts
Example 25 – Display SCI Input on LCD Using Receive Interrupts
Example 26 – Sending Periodic Acceleration Measurements to Matlab
Problems
9. The Serial Peripheral Interface (SPI)
9.1 Operation of the SPI
9.2 Programming the SPI in C and Assembly Language
Example 27 – Interfacing with the LTC1661 10-Bit DAC
9.3 Keypad Interfacing with 74165 Shift Registers
Example 28 – Reading Data from Shift Registers Using SPI
Problems
10. Timer
10.1 Output Compare
Example 29 – Interrupt-Driven Pulse Train
Example 30 – Playing Musical Notes with the Keypad
10.3 Input Capture
Example 31 – Measuring Input Pulse Widths
11. Fuzzy Control
11.1 Design of a Fuzzy Controller
11.2 Fuzzification of Inputs – MEM and fill_weights(…)
11.3 Processing the Rules – REV and fire_rules(…)
11.4 Output Defuzzification – WAV and calc_output(…)
11.5 Under the Hood – Fuzzy Control Assembly Routines
Problems
Appendix A – CodeWarrior Tutorial – DRAGON12-Plus-USB
Appendix B – HCS12 Assembly Language Essentials
Appendix C – Summary of C Function Calls to main.asm
Appendix D – MC9S12DG256B Interrupt Vectors
Appendix E – Introduction to Fuzzy Control
Appendix F – Phase Locked Loop
Appendix G – C Quick Reference Guide
Index
(211 pages)