SofTec Microsystems PK-HCS12E128 User manual


PK-HCS12E128
Starter Kit for
Motorola
MC9S12E128
User’s Manual
Copyright © 2003 SofTec Microsystems®
DC00713

We want your feedback!
SofTec Microsystems is always on the look-out for new ways to improve its Products and
Services. For this reason feedback, comments, suggestions or criticisms, however small,
are always welcome.
SofTec Microsystems
E-mail (general information): [email protected]
E-mail (marketing department): [email protected]
E-mail (technical support): suppor[email protected]
Web: http://www.softecmicro.com
Important
SofTec Microsystems reserves the right to make improvements to the PK Series of Starter Kits, their documentation and
software routines, without notice. Information in this manual is intended to be accurate and reliable. However, SofTec
Microsystems assumes no responsibility for its use; nor for any infringements of rights of third parties which may result
from its use.
SOFTEC MICROSYSTEMS WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA, PROFITS,
USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY
THEREOF.
Trademarks
Motorola and DigitalDNA are trademarks or registered trademarks of Motorola, Inc.
Metrowerks and CodeWarrior are trademarks or registered trademarks of Metrowerks Corp.
Microsoft and Windows are trademarks or registered trademarks of Microsoft Corporation.
PC is a registered trademark of International Business Machines Corporation.
Other products and company names listed are trademarks or trade names of their respective companies.
Written by Paolo Xausa

PK-HCS12E128 User's Manual
Contents
1. Overview 5
What is the PK-HCS12E128 Starter Kit? 5
Background Debug Module (BDM) 7
PK-HCS12E128 Board Layout 7
CodeWarrior Integrated Development Environment 8
Recommended Reading 9
Software Upgrades 9
2. Getting Started 11
PK-HCS12E128 Components 11
Host System Requirements 11
Installing the Software 12
Installing Metrowerks CodeWarrior IDE 12
Installing SofTec Microsystems Additional Components 12
Installing the Hardware 13
Application Tutorial 13
Additional Examples 17
3. Hardware Features 19
Introduction 19
MCU Section 19
USB to BDM Interface 20
Demo Section 20
Prototype Area 21
4. Debugging Features 23
Creating Your Own Application 23
Using the Project Wizard to Create Your Application Skeleton 23
Starting your first Debugging Session 24
Using Existing Projects with PK-HCS12E128 25
Breakpoints and Trace 27

Contents
Notes and Tips 28
Entering Debug Session with CodeWarrior 28
Reading Peripheral Status 28
Breakpoints and BGND Instruction 28
STOP Assembly Instruction 29
WAIT Assembly Instruction 29
Microcontroller Peripheral Running when Execution is Stopped 29
Real-Time Memory Update 29
PLL Usage 29
Hardware Breakpoints and Software Breakpoints 30
Advanced Debugging Features 30
DataBlaze Programming Utility 31
DataBlaze Notes 32
5. Troubleshooting 35
Common Problems and Solutions 35
Communication Can’t Be Established with PK-HCS12E128 35
Stepping Execution is Slow 36
Getting Technical Support 36
Appendix A. Electrical and Physical Specifications 37

PK-HCS12E128 User's Manual
Page 5
1
1. Overview
What is the PK-HCS12E128 Starter Kit?
The PK-HCS12E128 Starter Kit is an entry level tool which allows you to get started with the
Motorola MC9S12E128 microcontroller.
The main features of the MC9S12E128 microcontroller are:
§High-performance 16-bit HCS12 core;
§128 KB of FLASH memory;
§8 KB of RAM;
§Three asynchronous serial communications interface (SCI);
§A serial peripheral interface (SPI);
§An Inter-IC Bus (IIC);
§Three 4-channel, 16-bit timer module (TIM);
§6-channel, 8-bit Pulse Width Modulator (PWM);
§6-channel Pulse Width Modulator with Fault Protection (PMF);
§16-channel, 10-bit Analog-to-Digital converter (ADC);
§Two 1-channel, 8-bit Digital-to-Analog converter (DAC);
§Clock and Reset Generator (CRG);
§25 MHz bus speed;
§Input voltage range from 3.135 V to 5.5 V;
§Single-wire background debug mode (BDM);
§Enhanced Debug 12 Module, including breakpoints and change-of-flow trace buffer
(DBG12).
The PK-HCS12E128 Starter Kit has been designed for the evaluation of the MC9S12E128
microcontroller and the debugging of small user applications.

1. Overview
Page 6
1The PK-HCS12E128 Starter Kit takes advantage of the Metrowerks CodeWarrior Integrated
Development Environment (which groups an Editor, Assembler, C Compiler and Debugger)
and the Motorola BDM interface, which allows the download and debug of the user
application into the microcontroller’s FLASH memory.
Together with CodeWarrior, PK-HCS12E128 provides you with everything you need to
write, compile, download, in-circuit emulate and debug user code. Full-speed program
execution allows you to perform hardware and software testing in real time. PK-HCS12E128
is connected to the host PC through a USB port. A prototyping area allows you to wire your
own small application.
PK-HCS12E128 offers you the following benefits:
§Real-time code execution;
§In-circuit debugging;
§In-system programming and debugging through a BDM-compatible interface;
§Demo area with push-buttons, potentiometer and user LEDs;
§Prototyping area;
§Metrowerks CodeWarrior IDE (the same user interface of all Motorola tools), with editor,
assembler, C compiler and debugger.
Note: the PK-HCS12E128 starter kit has been designed for evaluation purposes only. Even
though it has full-feature debugging options, its main limitations are:
§The target microcontroller is fixed (soldered to the board).
§The data transfer rate (PC to target and target to PC) is slow. This results in high
programming times.
For serious debugging, we suggest you to switch to the SofTec Microsystems inDART-
HCS12 Series of debugging/programming tools.

PK-HCS12E128 User's Manual
Page 7
1
Background Debug Module (BDM)
All MCUs in the HCS12 family contain a single-wire background debug interface which
supports in-circuit programming of on-chip non-volatile memory and sophisticated non-
intrusive debug capabilities. This system does not interfere with normal application
resources. It does not use any user memory or locations in the memory map and does not
share any on-chip peripherals. The background debug module (BDM) uses a single-wire
communication interface to allow non-intrusive access to target system memory and
registers.
PK-HCS12E128 features a USB-to-BDM circuitry which allows the host PC to communicate
to the microcontroller through a standard USB cable.
PK-HCS12E128 Board Layout
The PK-HCS12E128 board has the following hardware features:
1. A “USB to BDM Interface” section. It contains the circuitry needed to electrically and
logically translate BDM-like commands sent by the host PC through the USB cable to
the BDM interface of the microcontroller. The PK-HCS12E128 board is powered (at 5 V)
by the USB bus.
2. A “Demo” section. It features a RESET push-button, two user push-buttons, a
potentiometer and eight user LEDs, plus a LED connected to a DAC output pin.
3. A “MCU” section. It contains a soldered, 112-pin MC9S12E128 device (in QFP
package) with connectors to access the I/O pins of the microcontroller for expansion
prototyping. A 16 MHz crystal oscillator (in Colpitts configuration) is provided, and the
microcontroller is configured to work in single-chip mode (MODA = MODB = 0).
4. A “Prototype” section. You can wire your own circuit here. The prototype section
features both a standard, thru-hole area (for mounting traditional components) and a
SMD area (for soldering SMD components in SOIC package).

1. Overview
Page 8
1
The PK-HCS12E128 Board
CodeWarrior Integrated Development Environment
PK-HCS12E128 comes with a free version of CodeWarrior Development Studio for
HC(S)12 Microcontrollers, Special Edition.
CodeWarrior Development Studio for HC(S)12 is a powerful and easy-to-use tool suite
designed to increase your software development productivity. Its Integrated Development
Environment (IDE) provides unrivaled features such as Processor Expert application design
tool, full chip simulation, Data Visualization and project manager with templates to help you
concentrate on the added value of your application.

PK-HCS12E128 User's Manual
Page 9
1
The comprehensive, highly visual CodeWarrior Development Studio for Motorola HC(S)12
Microcontrollers enables you to build and deploy HC(S)12 systems quickly and easily. This
tool suite provides the capabilities required by every engineer in the development cycle,
from board bring-up to firmware development to final application development.
To use the Special Edition (12 KB code-size limited), you must have a valid license key.
Without the license key the product will run in a 1 KB code-size limited demonstration mode.
To request the license key, please refer to Metrowerks website.
This documentation covers the basic setup and operation of the CodeWarrior IDE, but does
not cover all of its functions. For further information, please refer to the CodeWarrior on-line
help and on-line documentation provided.
Recommended Reading
This documentation describes how to use PK-HCS12E128 together with Metrowerks
CodeWarrior HC(S)12 IDE. Additional information can be found in the following documents:
§PK-HCS12E128 Schematic.
§Metrowerks’ Additional Documentation—Available from the CodeWarrior IDE.
§Motorola HCS12 Datasheets—Include detailed information on the devices’
background debug module.
Software Upgrades
The latest version of the PK-HCS12E128 system software is always available free of charge
from our website: http://www.softecmicro.com. Metrowerks CodeWarrior upgrades can be
found at http://www.metrowerks.com.


PK-HCS12E128 User's Manual
Page 11
2
2. Getting Started
PK-HCS12E128 Components
The PK-HCS12E128 package includes the following items:
1. The PK-HCS12E128 evaluation board;
2. AUSB cable;
3. The Metrowerks CodeWarrior HC(S)12 CD-ROM;
4. The SofTec Microsystems PK-HCS12E128 “System Software” CD-ROM;
5. A “QuickStart Tutorial” color poster;
6. This user’s manual.
Host System Requirements
The PK-HCS12E128 in-circuit debugger is controlled by an Integrated Development
Environment running under Windows (CodeWarrior HC(S)12). The following hardware and
software are required to run the CodeWarrior HC(S)12 user interface together with PK-
HCS12E128:
1. A 133-MHz (or higher) PC compatible system running Windows 98, Windows 2000 or
Windows XP;
2. 128 MB of available system RAM plus 500 MB of available hard disk space;
3. A USB port;
4. CD-ROM drive for installation.

2. Getting Started
Page 12
2
Installing the Software
Note: before to connect the PK-HCS12E128 board to the PC, it is recommended that you
install all of the required software first (see below), so that the PK-HCS12E128 USB driver
will be automatically found by Windows when you connect the board.
PK-HCS12E128 requires that both Metrowerks CodeWarrior IDE and SofTec Microsystems
PK-HCS12E128 additional components be installed in the host PC.
Note: Metrowerks CodeWarrior HC(S)12 IDE must be installed first. Please note that PK-
HCS12E128 only works with CodeWarrior for HC(S)12 version 3.0 or above.
Installing Metrowerks CodeWarrior IDE
To install the CodeWarrior IDE insert the CodeWarrior CD-ROM into your computer’s CD-
ROM drive. A startup window will automatically appear. Follow the on-screen instructions.
Installing SofTec Microsystems Additional Components
The SofTec Microsystems additional components install all of the other required
components to your hard drive. These components include:
§The PK-HCS12E128 USB driver;
§PK-HCS12E128 software plug-in for CodeWarrior HC(S)12;
§Examples;
§Documentation in PDF format.
To install the SofTec Microsystems additional components insert the SofTec Microsystems
“System Software” CD-ROM into your computer’s CD-ROM drive. A startup window will
automatically appear. Choose “Install Instrument Software” from the main menu. A list of

PK-HCS12E128 User's Manual
Page 13
2
available software will appear. Click on the “PK-HCS12 Series Additional Components”
option. Follow the on-screen instructions.
Note: if you are installing the PK-HCS12E128 additional components on Windows 2000 or
Windows XP you must have logged in as Administrator.
Installing the Hardware
The PK-HCS12E128 board is connected through a USB port to a host PC. Connection
steps are listed below in the recommended flow order:
1. Install all the required system software as described in the previous section.
2. Insert one end of the USB cable into a free USB port.
3. Insert the other end of the USB cable into the “USB” connector on the PK-HCS12E128
board. The green “POWER” LED on the instrument should turn on. Windows will
automatically recognize the instrument and will load the appropriate USB driver.
Note: both Windows 2000 and Windows XP may issue a warning the first time PK-
HCS12E128 is connected to the PC. This warning is related to the fact that the USB driver
used by PK-HCS12E128 is not digitally signed by Microsoft, and Windows considers it to be
potentially malfunctioning or dangerous for the system. However, you can safely ignore the
warning, since every kind of compatibility/security test has been carried out by SofTec
Microsystems.
Application Tutorial
This section will provide a step-by-step guide on how to launch your first PK-HCS12E128
project and get started with the CodeWarrior HC(S)12 user interface.

2. Getting Started
Page 14
2
The sample application reads the position of the potentiometer (connected to the
microcontroller’s ADC peripheral) and displays this value on the LEDs.
To execute the sample application, follow the next steps:
1. Ensure that the PK-HCS12E128 board is connected to the PC (via the USB cable).
2. Start the CodeWarrior HC(S)12 IDE by selecting Start > Programs > Metrowerks
CodeWarrior > CW12 > CodeWarrior IDE. The CodeWarrior HC(S)12 IDE will open.
3. From the main menu, choose File > Open. Select the “adc.mcp” workspace file that is
located under the “\Program Files\Metrowerks\CodeWarrior
CW12\(CodeWarrior_Examples)\MC9S12\SofTec Microsystems\PK-
HCS12E128\C\Adc” directory. Click “Open”. The following window will appear.
The Project Window
4. The C code of this example is contained in the “main.c” file. Double click on it to open.
The following window will appear.

PK-HCS12E128 User's Manual
Page 15
2
The Example’s Source Code
5. From the main menu, choose Project > Debug. This will compile the source code,
generate an executable file and download it to the PK-HCS12E128 board.
6. A new debugger environment will open.

2. Getting Started
Page 16
2
Debugging Session Started
7. From the main menu, choose Run > Start/Continue. The program will be executed in
real-time. By rotating the potentiometer on the PK-HCS12E128 board, you affect the
results of the A/D conversion, and the value of each conversion is displayed on the
LEDs.
8. From the main menu, choose Run > Halt. The program execution will stop. The next
instruction to be executed is highlighted in the Source window.

PK-HCS12E128 User's Manual
Page 17
2
9. From the main menu, choose Run > Single Step. The instruction highlighted in the
Source window will be executed, and the program execution will be stopped
immediately after.
10. In the Source window, insert a breakpoint at the “PTT = ATDDR0H;” instruction in the
main function. To insert the breakpoint, right-click on the “PTT = ATDDR0H;” line and,
from the pop-up menu, select “Set Breakpoint”.
11. Rotate the potentiometer slightly. Then, from the main menu, choose Run >
Start/Continue. The application will restart from where it was previously stopped. The
application will stop at the breakpoint location as soon as the next A/D conversion is
done.
12. Issue a Single Step command (Run > Single Step). The new value of the A/D
conversion will be displayed on the LEDs.
Congratulations! You have successfully completed this tutorial! You can continue to
experiment with the CodeWarrior user interface and discover by yourself its potentialities.
For an in-depth guide of all of the user interface features, select Help > CodeWarrior Help
from the CodeWarrior HC(S)12 IDE’s main menu.
Additional Examples
Additional examples can be found under the “\Program Files\Metrowerks\CodeWarrior
CW12\(CodeWarrior_Examples)\MC9S12\SofTec Microsystems\PK-HCS12E128”
directory.


PK-HCS12E128 User's Manual
Page 19
3
3. Hardware Features
Introduction
PK-HCS12E128 is an in-circuit debugger—it programs files into the MC9S12E128
microcontroller and offers debugging features like real-time code execution, stepping, and
breakpoints. Its debugging features are achieved thanks to the microcontroller’s integrated
Background Debug Module (BDM).
The BDM peripheral communicates with the host PC board (via the “USB to BDM Interface”
circuitry) through a dedicated, single-wire line (BKGD) of the microcontroller. The same line
is also used during device programming.
Contrariwise to traditional in-circuit emulation (where the target application is executed and
emulated inside the emulator), PK-HCS12E128 uses the very same target microcontroller to
carry on in-circuit execution. This means that all microcontroller’s peripherals (timers, A/D
converters, I/O pins, etc.) are not reconstructed or simulated by an external device, but are
the very same target microcontroller’s peripherals. Moreover, the PK-HCS12E128
debugging approach ensures that the target microcontroller’s electrical characteristics (pull-
ups, low-voltage operations, I/O thresholds, etc.) are 100% guaranteed.
MCU Section
The “MCU” section contains the target microcontroller and the additional circuitry needed for
the correct microcontroller startup. In detail:
§An MC9S12E128 microcontroller, together with all necessary filter capacitors.
§A 16-MHz crystal oscillator, connected to the microcontroller’s EXTAL and XTAL pins.
§The microcontroller’s MODA and MODB pins are connected to VSS (via pull-down
resistors) in order to enter the single-chip mode at startup.
§The microcontroller’s RESET pin is externally tied to VDD via a pull-up resistor. A push-
button in the “Demo” section is directly connected to this pin.
Table of contents
Other SofTec Microsystems Microcontroller manuals

SofTec Microsystems
SofTec Microsystems SK-S12 Series User manual

SofTec Microsystems
SofTec Microsystems ZK-HC08AX-A User manual

SofTec Microsystems
SofTec Microsystems ST7 Series User manual

SofTec Microsystems
SofTec Microsystems ZK-S12-B User manual

SofTec Microsystems
SofTec Microsystems DEMO9RS08KA2 User manual
Popular Microcontroller manuals by other brands

NimbeLink
NimbeLink Microchip chipKIT WF32 Shield user manual

Texas Instruments
Texas Instruments TMS570LS12x user guide

Faller
Faller 163701 instruction manual

Texas Instruments
Texas Instruments OMAP-L137/C6747 user guide

YDLIDAR
YDLIDAR X4PRO user manual

STMicroelectronics
STMicroelectronics STM32H7 user manual