did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9781401898120

The HCS12/9S12 An Introduction to Hardware and Software Interfacing

by
  • ISBN13:

    9781401898120

  • ISBN10:

    1401898122

  • Edition: CD
  • Format: Hardcover
  • Copyright: 2005-07-26
  • Publisher: Cengage Learning
  • View Upgraded Edition

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $295.95 Save up to $73.99
  • Buy Used
    $221.96
    Add to Cart Free Shipping Icon Free Shipping

    USUALLY SHIPS IN 2-4 BUSINESS DAYS

Supplemental Materials

What is included with this book?

Summary

This new book provides a total solution for learning and teaching embedded system design based on the Motorola HCS12/9S12 microcontroller. Readers will learn step-by-step how to program the HCS12 using both assembly and C languages, as well as how to use such development tools as asmIDE, MiniIDE, GNU C, and EGNU IDE. Supportive examples clearly illustrate all applications of the HCS12 peripheral functions, including parallel port, timer functions, PWM, UART port, SPI, I2C, CAN, on-chip flash and EEPROM programming, external memory expansion, and more. A back-of-book CD contains the source code for all examples in the book, several groups of reusable utility functions, and complimentary freeware development tools for improved learning.

Author Biography

Han-Way Huang is a Professor in the Department of Electrical and Computer Engineering and Technology at Minnesota State University, Mankato, MN.

Table of Contents

Preface
Introduction to the HCS12 Microcontroller
1(28)
Objectives
1(1)
Basic Computer Concepts
2(5)
The Processor
2(3)
Memory
5(2)
The Computer's Software
7(2)
The HCS12 CPU Registers
9(2)
Memory Addressing
11(1)
HCS12 Addressing Modes
12(6)
Inherent Mode
13(1)
Immediate Mode
13(1)
Direct Mode
13(1)
Extended Mode
14(1)
Relative Mode
14(1)
Indexed Modes
15(3)
Addressing More than 64 Kbytes
18(1)
HCS12 Instruction Examples
18(5)
The Load and Store Instructions
19(1)
Transfer and Exchange Instructions
20(1)
Move Instructions
21(1)
Add and Subtract Instructions
22(1)
Instruction Queue
23(1)
Instruction Execution Cycle
24(1)
Embedded Systems
24(2)
Summary
26(1)
Exercises
27(2)
HCS12 Assembly Programming
29(48)
Objectives
29(1)
Assembly Language Program Structure
30(2)
The Label Field
30(1)
The Operation Field
31(1)
The Operand Field
31(1)
The Comment Field
31(1)
Assembler Directives
32(3)
Software Development Issues
35(2)
Writing Programs to Do Arithmetic
37(13)
Carry/Borrow Flag
39(1)
Multiprecision Addition
40(2)
Subtraction and the C Flag
42(1)
Multiprecision Subtraction
42(1)
Binary-Coded-Decimal (BCD) Addition
43(2)
Multiplication and Division
45(5)
Program Loops
50(12)
Condition Code Register
53(1)
Branch Instructions
53(2)
Compare and Test Instructions
55(1)
Loop Primitive Instructions
56(3)
Decrementing and Incrementing Instructions
59(1)
Bit Condition Branch Instructions
60(2)
Instructions for Variable Initialization
62(1)
Shift and Rotate Instructions
62(6)
Boolean Logic Instructions
68(1)
Bit Test and Manipulate Instruction
69(1)
Program Execution Time
70(2)
The Multiply and Accumulate Instruction EMACS
72(1)
Summary
73(1)
Exercises
74(3)
Members and Hardware and Software Development Tools
77(48)
Objectives
77(1)
HCS12 Members
78(1)
Development Tools for the HCS12
79(1)
HCS12 Demo and Evaluation Boards
80(3)
The SSE256 Demo Board
80(2)
The Dragon 12 Demo Board
82(1)
The D-Bug12 Monitor
83(2)
The D-Bug12 Operating Modes
83(1)
EVB Mode
83(2)
Using a Demo Board with the D-Bug12 Monitor
85(21)
Starting the AsmIDE
87(1)
Communicating with the Demo Board
87(1)
Using the D-Bug12 Commands
88(11)
Entering an Assembly Program
99(1)
Assembling the Program
100(1)
Downloading the S-Record File onto the Demo Board for Execution
101(2)
Running and Debugging the Program
103(3)
Other D-Bug12 Modes
106(3)
The Pod Mode
106(1)
The Jump-to-EEPROM Mode
106(1)
The Bootloader Mode
107(2)
Tips for Assembly Program Debugging
109(5)
Syntax Errors
109(1)
Logical Errors
109(5)
BDM-Based Source-Level Debugger
114(7)
Overview of BDM
114(1)
BDM Commands
115(2)
BDM Serial Interface
117(1)
The BDM-Based Source-Level Debugger
117(1)
The DragonBDM from Wytec
118(1)
Using the Wytec DragonBDM Kit
118(3)
Summary
121(2)
Lab Exercises and Assignment
123(2)
Advanced Assembly Programming
125(56)
Objectives
125(1)
Introduction
126(1)
Stack
126(2)
Indexable Data Structures
128(4)
Strings
132(11)
Data Conversion
132(1)
Character and Word Counting
132(6)
Word Matching
138(3)
String Insertion
141(2)
Subroutines
143(2)
Issues in Subroutine Calls
145(1)
Parameter passing
145(1)
Result returning
146(1)
Allocation of local variables
146(1)
The Stack Frame
146(2)
Examples of Subroutine Calls
148(13)
Finding the Greatest Common Divisor
148(2)
Multiple Byte Division
150(4)
Bubble Sort
154(4)
Finding the Square Root
158(3)
Using the D-Bug12 Functions to Perform I/O Operations
161(12)
Calling D-Bug12 Functions from Assembly Language
162(1)
Descriptions of Callable Functions
163(7)
Using the D-Bug12 Functions
170(3)
Tips for Program Debugging Involving Subroutine Calls
173(2)
What to Do When the Program Gets Stuck
174(1)
General Debugging Strategy
174(1)
Summary
175(1)
Exercises
176(2)
Lab Exercises and Assignments
178(3)
C Language Programming
181(40)
Objectives
181(1)
Introduction to C
182(1)
Types, Operators, and Expressions
183(4)
Data Types
183(1)
Variable Declarations
183(1)
Constants
183(1)
Arithmetic Operators
184(1)
Bitwise Operators
184(1)
Relational and Logical Operators
185(1)
Precedence of Operators
186(1)
Control Flow
187(3)
If Statement
187(1)
If-Else Statement
187(1)
Multiway Conditional Statement
187(1)
Switch Statement
188(1)
For-Loop Statement
189(1)
While Statement
189(1)
Do-While Statement
189(1)
Goto Statement
190(1)
Input and Output
190(1)
Functions and Program Structure
191(2)
Pointers, Arrays, Structures, and Unions
193(6)
Pointers and Addresses
193(1)
Arrays
194(1)
Pointers and Arrays
195(1)
Passing Arrays to a Function
195(1)
Initializing Arrays
196(1)
Structures
196(2)
Unions
198(1)
Miscellaneous Items
199(2)
Automatic/External/Static/Volatile
199(1)
Scope Rules
199(1)
Type Casting
200(1)
Using the C Compiler
201(1)
Using the GNU C Compiler and EGNU IDE
201(13)
The GNU C Compiler
202(1)
The Procedure for Using the EGNU IDE
202(11)
Inline Assembly Instructions
213(1)
C Library Functions for the EGNU IDE
214(2)
Tips for C Program Debugging
216(2)
Summary
218(1)
Exercises
219(1)
Lab Exercises and Assignments
220(1)
Interrupts, Clock Generation, Resets, and Operation Modes
221(34)
Objectives
221(1)
Fundamental Concepts of Interrupts
222(4)
What Is an Interrupt?
222(1)
Why Are Interrupts Used?
223(1)
Interrupt Maskability
223(1)
Interrupt Priority
224(1)
Interrupt Service
224(1)
Interrupt Vector
225(1)
Interrupt Programming
225(1)
Overhead of Interrupts
226(1)
Resets
226(1)
HCS12 Exceptions
227(8)
Maskable Interrupts
227(3)
Nonmaskable Interrupts
230(1)
Interrupts in D-Bug12 EVB Mode
231(4)
Clock and Reset Generation Block (CRG)
235(10)
Modes of CRG Operation
236(1)
CRG Signals
237(1)
The Oscillator Block (OSC)
238(1)
Phase Locked Loop (PLL)
238(4)
System Clock Generation
242(3)
Clock Monitor
245(1)
Real-Time Interrupt (RTI)
245(1)
Computer Operating Properly
245(1)
Low-Power Modes
246(1)
The WAI Instruction
247(1)
The Stop Instruction
247(1)
Resets
247(1)
Power-On Reset
247(1)
External Reset
247(1)
HCS12 Operation Modes
248(2)
Normal Operation Modes
249(1)
Special Operation Modes
249(1)
Background Debug Mode
250(1)
Summary
250(1)
Exercises
251(1)
Lab Exercises and Assignments
252(3)
Parallel Ports
255(72)
Objectives
255(1)
Basic Concepts of I/O
256(1)
I/O Addressing
257(1)
I/O Synchronization
257(4)
Synchronizing the Microprocessor and the Interface Chip
258(1)
Synchronizing the Interface Chip and I/O Device
259(2)
Overview of HCS12 Parallel Ports
261(14)
Port Registers
262(1)
Port A and Port B
263(1)
Port E
263(4)
Port K
267(1)
Port T
267(2)
Port S
269(1)
Port M
270(2)
Ports H, J, and P
272(1)
Ports ADO and ADI
273(1)
Port L
274(1)
Ports U, V, and W
274(1)
Electrical Characteristic Considerations for I/O Interfacing
275(4)
Voltage-Level Compatibility
276(1)
Current Drive Capability
277(1)
Timing Compatibility
278(1)
Interfacing with Simple Input and Output Devices
279(8)
Interfacing with LEDs
279(2)
Interfacing with Seven-Segment Displays
281(5)
Liquid Crystal Displays (LCDs)
286(1)
The HD44780U LCD Controller
287(14)
Display Data RAM
289(2)
Character Generator ROM (CGROM)
291(1)
Character Generator RAM (CGRAM)
291(1)
Registers
291(1)
Instruction Description
292(1)
Interfacing the HD44780U to the HCS12 Microcontroller
293(8)
Interfacing with DIP Switches
301(2)
Interfacing Parallel Ports to a Keypad
303(6)
Keypad Scanning
303(1)
Keypad Debouncing
304(2)
ASCII Code Lookup
306(3)
Interfacing with a D/A Converter
309(3)
The AD7302 D/A Converter
309(1)
Interfacing the AD7302 with the HCS12
310(2)
Stepper Motor Control
312(7)
Stepper Motor Drivers
316(3)
Key Wakeups
319(3)
Key-Wakeup Registers
319(1)
Key-Wakeup Initialization
319(1)
Considerations for the Key-Wakeup Application
320(2)
Summary
322(1)
Exercises
323(2)
Lab Exercises and Assignments
325(2)
Timer Functions
327(76)
Objectives
327(1)
Why Are Timer Functions Important?
328(1)
Standard Timer Module
329(1)
Timer Counter Register
330(2)
Timer System Control Register 1
330(1)
Timer System Control Register 2 (TSCR2)
331(1)
Timer Interrupt Flag 2 Register (TFLG2)
331(1)
Input-Capture Function
332(9)
Input-Capture/Output-Compare Selection
332(1)
Pins for Input-Capture
333(1)
Registers Associated with Input-Capture
333(1)
Input-Capture Applications
334(7)
Output-Compare Function
341(18)
Operation of the Output-Compare Function
341(1)
Registers Related to the Output-Compare Function
342(1)
Applications of the Output-Compare Function
343(5)
Making Sound Using the Output-Compare Function
348(7)
Using OC7 to Control Multiple Output-Compare Functions
355(3)
Forced Output-Compare
358(1)
Pulse Accumulator
359(11)
Signal Pins
359(1)
Operation Modes
359(1)
Interrupt Sources
360(1)
Registers Related to Pulse Accumulator
361(2)
Operations of the Enhanced Pulse Accumulators
363(2)
Pulse Accumulator Applications
365(5)
Modulus Down-Counter
370(3)
Using the Modulus Down-Counter to Generate Periodic Interrupts
370(2)
Using the Modulus Down-Counter to Generate Time Delays
372(1)
Enhanced Capture Timer (ECT) Module
373(6)
Enhanced Capture Timer Modes of Operation
373(1)
Why the Enhanced Capture Timer Module?
374(1)
The Operation of the Enhanced Input-Capture Function
374(5)
Pulse-Width Modulation (PWM) Function
379(14)
PWM Clock Select
379(4)
PWM Channel Timers
383(10)
DC Motor Control
393(4)
Drivers
393(1)
Feedback
394(3)
Electrical Braking
397(1)
Summary
397(1)
Exercises
398(2)
Lab Exercises and Assignments
400(3)
Serial Communication Interface (SCI)
403(30)
Objectives
403(1)
Fundamental Concept of Serial Communications
404(1)
The RS-232 Standard
404(10)
EIA-232E Electrical Specification
404(1)
EIA-232E Functional Specification
405(3)
EIA-232E Mechanical Specification
408(1)
EIA-232E Procedural Specification
409(2)
Data Format
411(2)
Data Transmission Errors
413(1)
Null Modem Connection
413(1)
The HCS12 Serial Communication Interface
414(1)
SCI Baud Rate Generation
415(1)
The SCI Operation
416(8)
Character Transmission
417(3)
Break Characters
420(1)
Idle Characters
421(1)
Character Reception
421(1)
Receiver Wakeup
422(1)
Single-Wire Operation
423(1)
Loop Operation
423(1)
Operation of the SCI in Different MCU Modes
424(1)
Flow Control of USART in Asynchronous Mode
424(1)
Interfacing SCI with EIA-232
425(5)
Summary
430(1)
Exercises
430(1)
Lab Exercises and Assignment
431(2)
Serial Peripheral Interface (SPI)
433(56)
Objectives
433(1)
Introduction to the SPI Function
434(1)
SPI Signal Pins
434(1)
Registers Related to the SPI Subsystem
435(3)
SPI Operation
438(4)
Transmission Formats
438(2)
Bidirectional Mode (MOMI or SISO)
440(1)
Mode Fault Error
441(1)
Low Power Mode Options
441(1)
SPI Circuit Connection
442(2)
Configuration of and Data Transfer in SPI
444(3)
SPI-Compatible Chips
447(1)
The 74HC595 Shift Register
447(4)
The TC72 Digital Thermometer
451(7)
Functioning of TC72
451(1)
Temperature Data Format
451(1)
Serial Bus Interface
452(2)
Internal Register Structure
454(4)
The D/A Converter TLV5616
458(6)
Signal Pins
458(1)
Data Format
459(1)
TLV5616 Output Voltage
459(1)
Data Shifting Timing
459(1)
Interfacing the TLV5616 with the HCS12
460(4)
Matrix LED Displays
464(2)
The Organization of Matrix LED Displays
464(1)
Colors of Matrix LED Displays
464(1)
Connection Method
464(1)
Dimension of Matrix LED Displays
464(1)
Method of Driving Matrix LED Displays
464(2)
The MAX6952 Matrix LED Display Driver
466(17)
Pin Functions
467(1)
Internal Registers
468(7)
Blinking Operation
475(1)
Choosing Values for RSET and CSET
476(7)
Summary
483(1)
Exercises
484(3)
Lab Exercises and Assignment
487(2)
Inter-Integrated Circuit (I2C) Interface
489(62)
Objectives
489(1)
The I2C Protocol
490(11)
Characteristics of I2C Protocol
490(1)
I2C Signal Levels
490(1)
I2C Data Transfer Signal Components
491(2)
Synchronization
493(1)
Arbitration
494(1)
Data Transfer Format
495(1)
7-bit Addressing
496(2)
10-bit Addressing
498(3)
An Overview of the HCS12 I2C Module
501(1)
Registers for I2C Operation
502(7)
The I2C Address Register (IBAD)
502(1)
The I2C Control Register (IBCR)
502(1)
The I2C Status Register (IBSR)
503(2)
The I2C Data Register (IBDR)
505(1)
The I2C Frequency Divider Register (IBFD)
505(4)
Programming the I2C Module
509(4)
Generation of the Start Condition
510(1)
I2C Data Transfer in Master Mode
511(2)
I2C Data Transfer in Slave Mode
513(1)
The Serial Real-Time Clock DS1307
513(13)
Signal Functions
513(1)
RTC and RAM Address Map
514(1)
Clock and Calendar
515(1)
The DS1307 Control Register
516(1)
Data Transfer
516(1)
Circuit Connection
517(9)
The Digital Thermometer and Thermostat DS1631A
526(13)
Pin Assignment
526(1)
Functional Description
527(1)
DS1631A Registers
528(1)
The DS1631A Operation
528(2)
DS1631A Command Set
530(1)
I2C Communication with DS 1631A
531(8)
Interfacing the Serial EEPROM 24LC08B with I2C
539(9)
Pin Assignment and Block Diagram
539(1)
Device Addressing
540(1)
Write Operation
541(1)
Acknowledge Polling
541(1)
Read Operation
541(2)
Circuit Connection Between the I2C Master and the 24LC08B
543(5)
Summary
548(1)
Exercises
549(1)
Lab Exercises and Assignments
550(1)
Analog-to-Digital Converter
551(42)
Objectives
551(1)
Basics of A/D Conversion
552(6)
A Data Acquisition System
552(1)
Analog Voltage and Digital Code Characteristic
552(2)
A/D Conversion Algorithms
554(2)
Optimal Voltage Range for A/D Conversion
556(1)
Scaling Circuit
556(1)
Voltage Translation Circuit
557(1)
The HCS12 A/D Converter
558(10)
Signal Pins Related to A/D Converter
559(1)
Registers Associated with A/D Converter
560(8)
The Functioning of the ATD Module
568(3)
Analog Input Multiplexer
568(1)
ATD Module Clock
568(1)
Sample-and-Hold Stage
568(1)
Input Channel Wraparound
569(1)
FIFO Mode
569(1)
External Trigger Source
570(1)
Signed and Unsigned Control
570(1)
ATD Operation Modes
570(1)
Procedure for Performing A/D Conversion
571(4)
Using the Temperature Sensor TC1047A
575(6)
Using the IH-3606 Humidity Sensor
581(3)
Measuring Barometric Pressure
584(4)
Summary
588(1)
Exercises
588(3)
Lab Exercises and Assignments
591(2)
Controller Area Network (CAN)
593(60)
Objectives
593(1)
Overview of Controller Area Network
594(2)
Layered Approach in CAN
594(1)
General Characteristics of CAN
594(2)
CAN Messages
596(7)
Data Frame
596(3)
Remote Frame
599(1)
Error Frame
600(1)
Overload Frame
600(1)
Interframe Space
601(1)
Message Filtering
602(1)
Message Validation
602(1)
Bitstream Encoding
602(1)
Error Handling
603(1)
Bit Error
603(1)
Stuff Error
603(1)
CRC Error
603(1)
Form Error
603(1)
Acknowledgment Error
603(1)
Error Signaling
603(1)
Fault Confinement
603(1)
CAN Node Status
603(1)
Error Counts
604(1)
CAN Message Bit Timing
604(1)
Nominal Bit Time
604(1)
Length of Time Segments
605(1)
Synchronization Issue
605(1)
Resynchronization Jump Width
605(1)
Phase Error of an Edge
606(1)
Overview of the HCS12 CAN Module
606(2)
MSCAN Module Memory Map
608(20)
MSCAN Control Registers
608(10)
MSCAN Message Buffers
618(5)
Transmit Storage Structure
623(1)
Receive Storage Structure
624(1)
Identifier Acceptance Filter
625(1)
MSCAN Clock System
625(2)
MSCAN Interrupt Operation
627(1)
MSCAN Initialization
627(1)
Physical CAN Bus Connection
628(4)
The MCP2551 CAN Transceiver
629(1)
Interfacing the MCP2551 to the HCS12 CAN Devices
630(2)
Setting the CAN Timing Parameters
632(4)
MSCAN Configuration
636(2)
Data Transmission and Reception in MSCAN
638(10)
MSCAN Data Transmission Programming
639(2)
MSCAN Data Reception Programming
641(3)
Putting It All Together
644(4)
Summary
648(1)
Exercises
649(1)
Lab Exercises and Assignments
650(3)
Internal Memory Configuration and External Memory Expansion
653(154)
Objectives
653(1)
Introduction
654(1)
Internal Resource Remapping
654(5)
Register Block Mapping
655(1)
SRAM Mapping
656(1)
EEPROM Mapping
656(1)
Miscellaneous Memory Mapping Control
656(3)
Expanded Memory Mapping
659(2)
On-Chip Flash Memory
661(16)
Flash Memory Map
661(1)
Flash Memory Protection
661(3)
Flash Memory Related Registers
664(4)
Securing the Flash Memory
668(1)
Unsecuring the Microcontroller
668(2)
Configuring the FCLKDIV Register
670(1)
Flash Memory Programming and Erasure Algorithms
671(6)
The On-Chip EEPROM Memory
677(9)
EEPROM Memory Map
677(1)
EEPROM Associated Registers
677(4)
EEPROM Protection
681(1)
Configuring the ECLKDIV Register
681(1)
Programming and Erasure of EEPROM
681(5)
HCS12 External Memory Interface
686(7)
HCS12 Pins for External Memory Interfacing
686(2)
Waveforms of Bus Signals
688(1)
Bus Transactions
689(2)
Bus Multiplexing
691(1)
The HCS12 Bus Cycles
691(2)
Issues Related to Adding External Memory
693(3)
Memory Space Assignment
694(1)
Address Decoder Design
695(1)
Timing Verification
696(1)
Memory Devices
696(8)
The K6R1008C1D
696(1)
The AT28C010 EEPROM
697(7)
Example of External Memory Expansion for the HCS12
704(9)
Memory Space Assignment
706(1)
Address Latch
707(1)
Address Decoder Design
708(1)
Write Control Signals
708(1)
Example HCS12 External Memory Design
709(4)
Summary
713(1)
Exercises
714(1)
Lab Exercises and Assignments
714(1)
Appendices
A. Instruction Set Reference
715(22)
B. Summary Features of HCS12 Devices
737(4)
C. Tutorial for Using the MiniIDE
741(14)
D. MC9S12DP256 Registers
755(26)
E. LCD Functions for the SSE256 Demo Board
781(4)
F. Music Note Frequencies
785(4)
G. Using the MAX7221 LED Display Driver
789(18)
References 807(2)
Glossary 809(10)
Index 819

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

"This new book provides a total solution for learning and teaching embedded system design based on the Motorola HCS12/9S12 microcontroller. Readers will learn step by step how to program the HCS12 using both assembly and C languages, as well as how to use such development tools as asmIDE, MiniIDE, GNU C, and EGNU IDE. Supportive examples clearly illustrate all applications of the HCS12 peripheral functions, including parallel port, timer functions, PWM, UART port, SPI, 12C, CAN, on-chip flash, EEPROM programming, external memory expansion, and more. A back-of-book CD contains the source code for all examples in the book, several groups of reusable utility functions, and complimentary freeware development tools for improved learning."--BOOK JACKET.

Rewards Program