© Freescale Semiconductor, Inc., 2005, 2006. All rights reserved.
Freescale Semiconductor
Users Guide
HCS08QRUG
Rev. 1, 2/2006
This collection of code examples, useful tips, and quick
reference material has been created to help users speed
the development of their applications. Each section
within this document contains an example that may be
modified to work with HCS08 MCU Family members.
When you’re developing your application, consult your
device data sheet for part-specific information, such as
which versions of the peripheral modules are on your
device.
This book begins with a section about device
initialization, and then explores the different peripheral
modules found in the HCS08 Family of MCUs. It
concludes with two sections on implementing interrupt
subroutines and making memory usage assignments in
an embedded C environment with CodeWarrior.
Each section of this users guide contains:
• Programmer’s model register figure for quick
reference
• Example code
• Supplemental information supporting the code
All code is available inside a CodeWarrior project, or
from Freescale’s Web site in HCS08QGUGSW.zip.
In-depth material about using the HCS08 modules is also
available in Freescale’s application notes. See the
Freescale Web site: http://freescale.com
Using the Device Initialization . . . . . . . . . . . . . . . . . . . 3
Using the Low Voltage Detect System . . . . . . . . . . . 11
Using the Internal Clock Source (ICS) . . . . . . . . . . . 15
Using the Internal Clock Generator (ICG) . . . . . . . . . 23
Programming the Low-Power Modes. . . . . . . . . . . . . 29
Using the External Interrupt Request Function (IRQ) 33
Using the Keyboard Interrupt (KBI) . . . . . . . . . . . . . . 37
Using the Analog Comparator (ACMP) . . . . . . . . . . . 41
Using the 10-Bit Analog-to-Digital Converter (ADC) . 45
Using the Analog-to-Digital Converter (ATD) . . . . . . . 49
Using the Inter-Integrated Circuit (IIC) Module . . . . . 53
Using the Serial Communications Interface (SCI) . . . 63
Using the Serial Peripheral Interface (SPI) . . . . . . . . 69
Using the 8-Bit Modulo Timer (MTIM) . . . . . . . . . . . . 73
Using the Real-Time Interrupt (RTI) Function . . . . . . 77
Using the Input Capture and
Output Compare Functions . . . . . . . . . . . . . . . . 81
Generating PWM Signals
Using the HCS08 Timer (TPM) . . . . . . . . . . . . . . 87
Programming and Erasing Flash Memory . . . . . . . . . 91
Implementing Interrupt Service Routines (ISR) in C
Using CodeWarrior . . . . . . . . . . . . . . . . . . . . . . 95
Memory Mapping for HCS08 Family MCUs Using
CodeWarrior Software . . . . . . . . . . . . . . . . . . . 103
HCS08 Peripheral Module
Quick Reference
A Compilation of Demonstration Software for HCS08 Modules
Topic Reference