Designing with Microcomputers -- The 68HCS12

Designing with Microcontrollers -- THe 68HCS12 has been available to the public since July 2004, and is now in a revised version 7. I've used used this HTML based text and the predecessor for a two term (20 week) Microcontroller Systems course sequence at Oregon Institute of Technology, Portland campus, since 1999. During that time it has had frequent revisions to clarify confusing issues and to cover additional topics students wanted. The resulting text is terse and no-nonsense but covers more material than a typical microcontroller text. While the text is revised for covering the 68HCS12 and to use with the Wytec Dragon12-Plus development board and other MC9S12DP256 family boards, it is useful for other development boards, including MC9S12C family based boards, as well as earlier 68HC12 family members.

You can view an 11 minute HD video on installing the CD, setting up the Dragon12-Plus board and running a simple example program on the board and on the simulator here.


Here's a brief description of what is covered in each of the text sections. The sections on the Parallel I/O Ports can be read on this site to get an idea of the content. The Alarm Clock Example is provided in abridged form here as a project example.

  1. Microcontroller Overview - the basics for those who don't know what a microcontroller is.
  2. Binary Number Representation - basic arithmetic functions and base conversion. Negative number representation
  3. The Central Processing Unit (CPU) - generic operation of ALU, CPU registers, memory interfaces, and specifics for HCS12 family
  4. Development Tools - survey of development tools. Introduction to flowcharts.
  5. 68HC12/68HCS12 Instruction Set Overview - instruction set classified, addressing modes, basics of instruction timing
  6. Load, Store and Move Instructions
  7. Arithmetic Instructions
  8. Branching and Iteration - condition codes, loops with pre-test, loops with post-test
  9. Using Tables and Arrays - defining and accessing tables and arrays. Interpolating between entries. Tables for format conversion.
  10. Decision Trees and Logic Instructions - selection control structures, Boolean logic and CPU instructions, handy summary
  11. The Stack and Subroutines - stacks for data storage. Using subroutines. Passing parameters and results.
  12. Input/Output Overview
  13. Electrical Characteristics - interfacing CMOS and TTL, timing considerations, power and ground.
  14. General Purpose I/O Pins - use of general purpose I/O pins (ports)
  15. Parallel I/O Ports - parallel I/O. Handshaking techniques. Parallel I/O using the memory interface.
  16. System Clocks - Using the phase-locked loop.
  17. Interrupts, Traps, and Resets - basics of interrupts and operation in the 68HCS12
  18. External Interrupts - IRQ, XIRQ, and key wake-ups.
  19. The RTI and COP interrupts - Computer Operating Properly clock monitor, "watchdog" failure, and the "Real Time" interrupt.
  20. The Timer Module -- using all the features of the Timer Module as common with the 68HC12
  21. Pulse Width Modulation - using the PWM module
  22. The Analog to Digital Converter - covers all the features of the ATD module
  23. External Memory/Peripheral Interfacing - first covers 8 and 16 bit modes of the 68HC12, which has a simpler interface and is intended for memory expansion, then covers the 68HCS12 used on the DRAGON12/Dragon12-Plus which is intended mainly for single chip operation. Chip selects, clock stretch, and memory expansion features are covered.
  24. Serial Communications Interface - the history of serial communication from the telegraph to the RS232 computer interface, and, of course, how to use it in the 68HCS12. Interrupt driven buffering techniques for input, output, and a line-oriented interface for human interaction.
  25. Serial Peripheral Interface - various ways to use the SPI, with single and multiple external devices, including the bidirectonal interface.
  26. Inter-Integrated Circuit (I2C) Interface - how it works and how to use it, driver code provided.
  27. Other Serial Interfaces - on overview of the other serial interfaces in the 68HCS12 -- BDLC, CAN, and BDM. This section also covers interfacing Harris 1-Wire devices.
  28. EEPROM Memory and Internal Resource Mapping
  29. Scaled Integer Arithmetic - binary and fractional scaling of integers
  30. Floating Point Arithmetic - floating point arithmetic design (IEEE standard short) and use. A simple library is provided for student use.
  31. Fuzzy Logic - a basic introduction to fuzzy logic, from a hard logic point of view, and the supporting instructions in the 68HCS12

The following sections are provided in the appendix:

There are study questions and/or projects for each of th 31 sections -- a total of 256 questions, 32 with answers provided, and 47 projects.

How I've used the text in class

I teach the sequence as basically four 5-week units. The first unit covers the basics of microcontrollers and programming. This corresponds to sections 1-11 of the text. I've found from earlier experience that it is difficult to have meaningful assignments involving the peripheral modules and interfacing if programming is not understood. The next two units cover the peripheral modules and interfacing (sections 12-18 then 19-22). Particular attention is placed on using interrupts. My approach is that interrupts are nothing to fear, and lead to simpler, more modular designs. The final unit returns to software (sections 23-26 and appendices), covering advanced arithmetic and designing systems for applications. Practical experience is the best way to approach applications, and all students engage in a project of their own choosing using the microcontroller and external hardware.

Revisions add topics

Particularly important for class use, revisions add topics but never remove them or change their order so there is never a forced revision of lesson plans. On the other hand, by having the text CD-based and printed on-demand, revisions can be made far more frequently than a traditional textbook, so the material can be corrected and kept fresh.

Version 7A, new July 2015, corrects many minor or typographical errors.

Version 7, new July 2011, corrects 4 errors and adds some additional example code.

Version 6, new July 2009, adds coverage for interfacing Harris 1-Wire devices. The appendix on multiple processes is enlarged as well.

Version 5, new August 2008, corrects the errors in the previous version, has a revised and enlarged first chapter, an added integer scaling example, and has been completely revised for the Dragon12-Plus board, eliminating references to the previous board, no obsolete.

Version 4, new June 2007, adds section questions and has a new appendix on the MC9S12C family. The simulator is revised with drag-and-drop assembly and loading, support for MC9S12C microcontrollers, and simulation of an SPI port. There were dozens of smaller changes as well. The text and simulator now assume an 8 MHz crystal.

Version 3, new in the summer of 2006, included a new section with an overview of the BDLC, CAN, and BDM serial interfaces and an alarm clock project example writen in C. The simulator was improved over the initial Version 2 release. The CD has been verified for use on Microsoft Windows 2000 and XP, as well as Mac OS 10.3 or later and Linux systems.

Version 2 additions over Version 1 included a new section on the IIC module, sample C code for I/O and interrupt handling (GNU C compiler) as well as additional C code to illustrate addressing modes. Several new example programs, runnable from the simulator or on the hardware, had been added. Extra narrative and illustrations had been added in places where students have had difficulties with the concepts. There was a much improved installation approach placing everything on the Windows Start menu, although the simulator, text, and examples can still be accessed directly from the CD without installation on the hard drive.

Still have questions?

Questions? Contact me at