HCS12 BDM Getting Started V4.3

Similar documents
Freescale 68HCS12 Family On-Chip Emulation

NEC 78K0- Family On-Chip Emulation

_ V ST STM8 Family On-Chip Emulation. Contents. Technical Notes

_ V Intel 8085 Family In-Circuit Emulation. Contents. Technical Notes

Renesas 78K/78K0R/RL78 Family In-Circuit Emulation

_ V Renesas R8C In-Circuit Emulation. Contents. Technical Notes

Freescale S12X Family In-Circuit Emulation

_ V1.3. Motorola 68HC11 AE/AS POD rev. F. POD Hardware Reference

Contents. Cortex M On-Chip Emulation. Technical Notes V

Cortex-M3 Family On-Chip Emulation

_ V Freescale ColdFire Family On-Chip Emulation. Contents. Technical Notes

_ V PowerPC 4xx Family On-Chip Emulation. Contents. Technical Notes

Trace Getting Started V8.02

_ V1.3. MPC564xB ActiveGT POD. POD Hardware Reference

_ V NEC V850ES/Fx3 Family In-Circuit Emulation. Contents. Technical Notes

Evaluation & Development Kit for Freescale PowerPC MPC5517 Microcontroller

_ V1.1. EVB-5566 Evaluation & Development Kit for Freescale PowerPC MPC5566 Microcontroller. User s Manual. Ordering code

_ V Intel 8051 Family In-Circuit Emulation. Contents. Technical Notes

NEW CEIBO DEBUGGER. Menus and Commands

All information, including contact information, is available on our web site Feel free also to explore our alternative products.

PK-HCS12C32 Starter Kit for Motorola MC9S12C32 User s Manual

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Programming in the MAXQ environment

All information, including contact information, is available on our web site Feel free also to explore our alternative products.

Barracuda I and II Chips (I mask is OK36N and II mask is OK79X) PC9S12DP256

Application Note, V1.0, Aug AP08064 XC866/886/888. Safeguarding the Microcontroller under Out-of-Spec Noise Conditions.

CEIBO FE-51RD2 Development System

This document describes support for OSEK operating system used with winidea.

EETS2K Block User Guide V01.03

indart -HCS08 In-Circuit Debugger/Programmer for Freescale HCS08 Family FLASH Devices User s Manual Rev. 2.0

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Sophisticated Debugging Features for Motorola s HCS12 Family are available on Nohau s Full-Featured Emulator By: Doron Fael Nohau

Module Introduction. PURPOSE: The intent of this module is to explain MCU processing of reset and interrupt exception events.

_ V1.1. Motorola 6809 B POD rev. C. POD Hardware Reference

_ V1.2. Motorola 68HC08 JL POD rev. D1. POD Hardware Reference

E8a Emulator Additional Document for User's Manual R0E00008AKCE00EP9

EB-51 Low-Cost Emulator

Background Debug Module (BDM) V4 HCS12. Microcontrollers. S12BDMV4/D Rev /2004 MOTOROLA.COM/SEMICONDUCTORS

E8a Emulator Additional Document for User's Manual R0E00008AKCE00EP2

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

EETS4K Block User Guide V02.06

All information, including contact information, is available on our web site Feel free also to explore our alternative products.

HI-WAVE. Serial Debug Interface SDI target. Copyright 1997 HIWARE HI-WAVE

SX Device In-System Programming Specifications

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Chapter Operation Pinout Operation 35

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

Product Update. Errata to Z8 Encore! 8K Series Silicon. Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later

ToolStick-EK TOOLSTICK USER S GUIDE. 1. Kit Contents. 2. ToolStick Overview. Green and Red LEDs. C8051F321 provides USB debug interface.

CEIBO FE-W7 Development System

CEIBO FE-5111 Development System

Bolero Nexus Emulation Adapter 208BGA 100TQ

Freescale Semiconductor, Inc. Debugger. Serial Debug Interface SDI target. Copyright Metrowerks Debugger

System Reset / C167. Figure 17-1 External Reset Circuitry. Semiconductor Group 17-1

All information, including contact information, is available on our web site Feel free also to explore our alternative products.

8051 Microcontroller

Introduction to the Altera SOPC Builder Using Verilog Designs. 1 Introduction

S12 All-Access Bootloader for the HCS12 Microcontroller Family Rafael Peralez and Gabriel Sanchez RTAC Americas

HandsOn Technology -- HT-MC-02 MODEL: HT-MC-02

E8a Emulator Additional Document for User's Manual R0E00008AKCE00EP21

M68EM05X4 EMULATOR MODULE USER'S MANUAL

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

Introduction to ARM LPC2148 Microcontroller

M16C/62P QSK QSK62P Plus Tutorial 1. Software Development Process using HEW4

Bolero3M Nexus Emulation Adapter 256BGA 176TQ

Chapter 7 Central Processor Unit (S08CPUV2)

TMS320LF240x-A Flash Programming

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

RFlasher7. Getting Started and Overview. Document version

AC/DC. Adapter. Serial. Adapter. Figure 1. Hardware Setup

Figure 1. JTAGAVRU1 application The JTAGAVRU1 is supported by AVR Studio. Updated versions of AVR Studio is found on

Laboratory Exercise 3 Comparative Analysis of Hardware and Emulation Forms of Signed 32-Bit Multiplication

The purpose of this course is to provide an introduction to the RL78's flash features and archectecture including security features, code and data

Megawin 8051 OCD ICE

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their

Introduction to 8051 microcontrollers

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

EUROScope lite 16FX Reference Manual

Introduction to the Altera SOPC Builder Using Verilog Design

CMS-8GP32. A Motorola MC68HC908GP32 Microcontroller Board. xiom anufacturing

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

EVBQE128. Evaluation Board for Freescale Flexis QE128. User s Manual

Tools Basics. Getting Started with Renesas Development Tools R8C/3LX Family

Hello, and welcome to this presentation of the STM32L4 power controller. The STM32L4 s power management functions and all power modes will also be

AC/DC. Adapter. Ribbon. Cable Serial. Serial. Adapter. Figure 1. Hardware Setup using an EC2 Serial Adapter

SKP16C26 Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

IAR C-SPY Hardware Debugger Systems User Guide

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

CROSSWARE 7 V8051NT Virtual Workshop for Windows. q Significantly reduces software development timescales

EasyIAP Software Example User s Guide

User s Manual Copyright SofTec Microsystems. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc.

DoCD IP Core. DCD on Chip Debug System v. 6.02

Infineon DAP Active Probe

1. Attempt any three of the following: 15

MICROPROCESSOR MEMORY ORGANIZATION

ST SPC58 B Line Emulation Adapter System

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

MICROPROCESSOR BASED SYSTEM DESIGN

Transcription:

HCS12 BDM Getting Started V4.3

Background The term BDM stands for Background Debug Mode. It is used for the system development and FLASH programming. A BDM firmware is implemented on the CPU silicon providing a comprehensive set of debug functionalities. Since BDM control logic does not reside in the CPU core, BDM hardware commands can be executed while the CPU is operating normally. The control logic generally uses CPU dead cycles to execute these commands, but can steal cycles from the CPU when necessary. Other BDM commands are firmware based, and require the CPU to be in active background mode for execution. While BDM is active, the CPU executes a firmware program located in a small on-chip ROM that is available in the standard 64-Kbyte memory map only while BDM is active. To stop the CPU after reset, BDM must be enabled (first phase) and activated (second phase). After reset, the BDM is neither enabled nor active, except when CPU is started in the special single chip mode. The debugger enables and activates it when necessary. In the special single chip mode, BDM is enabled and active immediately after reset. The BDM control logic communicates with an external development system serially, via the BKGD pin. This single-wire approach minimizes the number of pins needed for the development support. BDM is mainly used as a low cost debugging solution, for FLASH programming or in cases where the CPU is soldered in the target board. When the user s program is stopped, the CPU enters and operates in the BDM mode. Note that internal peripheral timers, previously active in the user s program, remain active after the BDM mode is entered. However, interrupts are disabled when BDM mode is entered. Single-chip Applications When debugging single chip application, the program runs from internal CPU memory resource, normally flash, but it can be EEPROM or RAM as well. Two hardware breakpoints or unlimited number of software breakpoints can be set in the code. Debugger s performance is reduced when setting or removing software breakpoint in the flash due to the fact that the debugger must erase and reprogram complete flash sector when modifying single memory location. While debugging the application residing in the RAM, software breakpoints use doesn t impact on the performance since the memory can be modified by a memory write. Hardware breakpoint resources are shared between several functionalities, which are excluding each other. The user can set 2 execution breakpoints in the program or use trace or configure access breakpoints. When there is a need to use trace or access breakpoints, the user must switch to software breakpoints use or don t use execution breakpoints. Note that software breakpoints don t function well with self-modifying code. Expanded Applications In expanded applications where the program remains in the internal flash, the debugging keeps the same. Such application will normally expand only to gain more RAM memory for data or additional peripheral device(s). If the application expands to gain more program space, then the debugger offers standard software breakpoints and hardware breakpoints in RAM memory and hardware breakpoints only (for the time of writing this document) in the external flash (ROM).

Taking control over the CPU after reset The debugger can force two CPU operating modes in which the CPU behaves differently: Normal mode some registers and bits are protected against accidental changes Special mode allows greater access to protected control registers and bits for special purposes such as testing and emulation. The debugger can force the CPU to active BDM mode immediately after the reset while the CPU operates in special single-chip mode. Additionally, the CPU can operate in single chip, expanded wide and expanded narrow mode. Refer to the CPU datasheet for more details on CPU operating modes. In special single chip mode, the on-chip BDM firmware is active immediately out of the reset. The CPU is stopped immediately after reset and the debugger has complete control over the CPU. IN ANY OTHER MODE THAN SPECIAL SINGLE CHIP, the on-chip BDM firmware is not active out of the reset and the CPU cannot be stopped immediately. After releasing the reset line, the CPU starts to execute the program and in the mean time, the debugger synchronizes with on-chip BDM firmware, activates and enables it, stops the CPU and gains control over the CPU. Now, the problem pops up when the flash is empty or contains the program not being operational. In such case, the CPU may hang already while the debugger synchronizes with the on-chip BDM and tries to gain the control over the CPU. If the CPU hangs, the debug connection cannot be established. In such case, the only alternative is to program the flash using special single chip mode in which the debugger controls the CPU immediately after reset. After the flash contains a valid program, It s recommended to check Execute software reset after hardware reset option in the CPU Setup dialog in all operating modes, except in special single-chip mode. When the option is checked, the CPU starts executing the code and after approx. 500us after reset is released, a BDM communication is established, CPU stopped, reset vector read and program counter preset to that address. Internal RAM and EEPROM Run, stop and single step debug commands can be used in the RAM or EEPROM. Up to two hardware breakpoints or unlimited number of software breakpoints can be set in the internal RAM and EEPROM. The RAM memory can be modified using memory window and the code can be loaded to the RAM using target download. Refer to Download section for more details on target download. A specific CPU configuration is required prior to be able to write to the EEPROM using memory window or to load the code in the EEPROM using target download. The debugger supports and recognizes any memory write attempt to the EEPROM. However, there are things that the user needs to be aware of and configure the CPU accordingly. Facts: 1) On some CPUs (e.g. MC9S12DP256) the EEPROM is after reset partially covered with I/O area. Therefore, not all EEPROM is available after reset due to the fact that I/O area has higher priority than the EEPROM. 2) The CPU has an EEPROM Protection Register (EEPROT). With this register, a certain EEPROM area(s) can be protected against unwanted writes. If a certain area is protected, the emulator (and the user program) cannot change the EEPROM contents. 3) The CPU has an ECLKDIV register, which controls the EEPROM clock. A correct division factor must be written to achieve the required EEPROM clock frequency (150-200kHz). The emulator does not write to this register to protect the EEPROM against unwanted writes. 3

To download the code in the EEPROM: 1) 'Target download must be used. 2) The ECLKDIV register must be set using the initialization sequence ( Hardware/Emulation Options/Initialization tab). 3) The EEPROM must be relocated from its reset location over the INITEE register using the initialization sequence. Note that this applies only for CPUs where after reset the EEPROM is partially covered with the I/O area and when complete EEPROM is required. 4) EEPROM writes must not be disabled. Interrupts While stopped, the CPU cannot service interrupts. If interrupts are generated in the meantime, they are pended. After resuming the user s program, interrupts are first executed by priority and then the user s program. The application may behave differently when using breakpoints while interrupts are active. If Interrupts Enabled When Stopped option is not checked, the debugger temporarily masks global interrupt flag while executing code and source single. This assures that the program doesn t enter in the interrupt routine while stepping through the code, which could happen if there would be an active periodical interrupt with a very short period. When the option is checked, the debugger doesn t alter interrupt flag when executing single step. Hardware Breakpoints The on-chip BDM firmware contains a breakpoint logic providing two execution breakpoints that can be set on any address in the CPU space. The user can use one breakpoint freely. The second one can be firmly reserved for the debugger that needs it for carrying out a high-level source step or can be used by the user. When it s required as an execution breakpoint too, the Reserve one breakpoint for high-level debugging option must be unchecked in the Options field in the Debugging tab in the Debug/Debug Options dialog. When one breakpoint is not firmly reserved for the debugger, highlevel source step will not fail as long as there is one breakpoint free. 4

Software Breakpoints Unlimited software breakpoints in the CPU internal flash are available. The debugger erases and programs complete belonging flash sector when setting or removing a breakpoint. Debug source step is implemented by using breakpoints too. Have this in mind when using software breakpoints. In worst case, the CPU internal flash can be worn out after long debugging due to a limited number of flash program cycles. When software breakpoints are used, they must be selected in the Breakpoints field and option Allow modification in the FLASH field must be checked, which enables flash modification by the debugger, that is when setting/clearing breakpoints or when writing manually in the flash using memory window. While gaining unlimited number of breakpoints, the debugger s performance drops down due to the flash programming process required for each breakpoint being set or cleared. A time that is required for carrying out a single source step is increased visibly comparing to a debug session using hardware breakpoints. 5

Real-Time Access BDM debugger can access all CPU s memory resources, like external memory, internal FLASH, EEPROM, RAM and SFRs, without disturbing the program being executed. Using hardware commands and on-chip BDM firmware, the debugger can access required resources in real time. In general, on-chip BDM firmware uses CPU dead cycles, when real-time read or write memory access is required. In worst case, some CPU cycles might be stolen. Real time access is possible for real-time watches, memory window and SFRs window. Real-time watches Real-time access is enabled in the Debug/Debug Options dialog. Check the Allow real-time memory access option in the Memory Access tab and the Update when running option in the Update tab. 6

SFRs window Real-time access is enabled in the Options dialog available from the SFRs window local menu. The Real Time (if available) option must be checked also when inspecting SFRs in the real-time watches, otherwise they won t be updated properly. Memory window Real-time access is enabled in the Display Mode dialog available from memory window local menu. Check the Real-time access option. 7

Monitor Access When monitor access to the CPU memory is requested while the application is running, the emulator stops the CPU, reads the requested number of bytes and resumes the application. All CPU memory can be accessed using monitor access. The drawback to this method is that memory cannot be accessed while the CPU is running without affecting the real-time execution. The time the CPU is stopped for is relative and cannot be exactly determined. The debugger has full control over it. On a request it stops the CPU, updates all open debug windows and sets the CPU back to running. Therefore, the time depends on the communication type used, PC where winidea is running, CPU clock, number of updated memory locations (memory window, SFR window, watches, variables window), etc. Download A code residing in the internal RAM, EEPROM or in the target RAM is downloaded using Target Download and a code residing in the internal flash is programmed over the FLASH Program dialog. winidea expects bank addresses in the download file by default. It s recommended that the project is compiled in a way that the download file contains bank addresses. If that's not possible and the file contains, for instance, linear addresses, the user must force linear memory space by selecting Linear in the Memory area combo box when specifying the download file. The 'Enabled' option in the Hardware/Emulation Options/CPU Setup/Memory Expansion tab must be checked if the code is linked for a bank application. It must be unchecked, if it s a non-bank project. Target Download Target Download can be accomplished in two different ways: File defined as a standard debug download file 8

Download files must be added in the Download Files tab in the Download dialog. Download files must be selected from the Target download combo box and debug command Download must be used to perform the actual download. 9

File defined as a target download file Download files must be added in the Target Download tab in the Download dialog. Target download files must be selected from the Target download combo box and debug command Download must be used to perform the actual download. When having a problem to download the code in the internal EEPROM, please read Internal RAM and EEPROM section on page 3. FLASH Programming Few parameters must be set in the FLASH/FLASH Programming Setup dialog (FLASH/Setup ) before the internal flash can be actually programmed. 10

When the CPU internal flash is programmed, winidea takes care of most of the necessary settings. Don t check Verify on the fly option since it s not supported on this CPU family (July 2004). Next, flash programming type must be selected. WinIDEA supports flash programming through the debug BDM port and fast FLASH monitor. Press Hardware Setup button in the Target tab in the FLASH Programming Setup dialog for the selection. Normally, the user should go straight for fast FLASH monitor use. Programming through the BDM port is much slower and recommended to be used when troubleshooting flash programming. Flash programming through FLASH monitor can be sped up by using on-chip PLL. Programming the code into the internal flash is actually executed by the CPU, executing a special flash programming monitor in the internal CPU RAM. Thereby, flash programming monitor execution depends on the system CPU clock. If the Use fast PLL setting during download option in the Hardware/Emulation Options/CPU Setup/Clock tab is checked, the debugger presets PLL to the maximum CPU clock and then programs the flash. After the flash programming is completed, the debugger resets the CPU to put the CPU back in the reset state. If presetting PLL to the maximum CPU frequency fails, the debugger programs the flash at CPU default frequency without warning the user. PLL may fail to lock at maximum CPU frequency due to the target PLL loop filter not being present or simply not designed for the maximum CPU frequency. A file or more files to be programmed can be selected in the Download files tab within the FLASH Programming Setup dialog. The alternative is to specify file(s) in the Debug/Files for Download/Download files tab, where normally files for debug download are specified. Make sure that Use Debug download files option ( Target tab in the FLASH Programming Setup dialog) is checked then. In first case, the option must be unchecked. 11

FLASH Program dialog should be invoked from the FLASH menu after the flash programming is configured in the FLASH Programming Setup dialog. Normally, check boxes beside Load Files, Erase, Program and Verify buttons should be checked. Flash programming is started by pressing Start button. During the flash programming, a status and eventual errors are displayed in the dialog. The debugger can program the flash automatically before the download without any need for opening the FLASH Program dialog by the user. Then before download in the Auto program FLASH combo box must be selected. 12

Debugging application using PLL After the PLL is activated, the CPU system clock changes and consequently the BDM clock. The debugger must synchronize to a new frequency, otherwise BDM communication falls out. Reset and PLL operating frequency must be entered in the Clock tab in the CPU Setup dialog. After reset, the debugger connects to the on-chip BDM at reset frequency. There are less startup problems when using special single chip mode since the CPU stops immediately after reset. With any other CPU operating mode, a small portion of the program is executed before the CPU can be stopped after reset. This portion of the program must not initialize and engage the PLL yet or the debugger will fail to establish the control over the application. Use special single chip mode whenever it s possible. In any other mode, the user must assure that the PLL is not enabled within first 500μs of program execution. In worst case, the user must add a delay in his program to meet the requirements. When the CPU is stopped after reset, the user can use step command to step through the program up to the PLL initialization routine since the debugger keeps using reset frequency. It s dissuaded to step through the PLL initialization routine. 13

As soon as the CPU is set into running for the first time (this excludes source and code single step), the debugger will use the operating frequency to communicate with the on-chip BDM. It s recommended that the PLL is engaged shortly after the application resumes, which is normally the case. However, if that s not the case, make sure that the application is not stopped before the PLL is engaged and the debugger is configured adequately. The user needs to estimate the time between the point when the program is resumed and when the PLL is actually engaged in the application and then enter it in seconds in the Wait for application to configure PLL field. Tip: Use After download run until option in the Debug/Files for download/download Options tab and define the source line located after the PLL initialization routine. By doing so, you won t need to worry about the PLL any longer since the debugger will already use new PLL clock when it stops. Troubleshooting First, check the PLL filter Make sure it s implemented and has proper values. Note that PLL loop filter values depend on the reset and operating frequency. Check the CPU, since some masks have design flaw and cannot be debugged when using PLL. Debugging application using COP The debugger needs no watchdog awareness while the watchdog is disabled. Following explanation is irrelevant for applications not using COP. When using COP, it s expected to be serviced properly by the application. When the debugger stops the CPU for the first time after reset (system initialization), a specific CPU register (COPCTL) must be written properly to enable COP support during debugging. When the user s program is stopped during the debugging, the CPU enters BDM mode in which the COP timer must be stopped. RESET From Target Enabled option in the CPU Setup/Options tab must be checked when COP is used in the application. If it s not checked, the debugger cannot detect any reset source including COP. Normal mode In normal mode, COP is disabled after reset. Additionally, the CPU cannot be stopped immediately after reset. The CPU executes the user s program for approximately 500μs before it can be stopped by the debugger, which then enters in the active BDM mode. After the CPU enters in the active BDM mode for the first time, RSBCK bit in the COPCTL register is set first. The user must enter the COPCTL value used in the application in the Advanced dialog. Do note that the user s application must not write COPCTL register before the application is stopped for the first time by the debugger. This is necessary due to the reason that the COPCTL is write once register. Therefore, at least within 500us after reset, the application must not write to the COPCTL register or it must write the same value as the debugger (RSBCK=1). 14

HCS12 Advanced tab in the CPU Setup dialog Special mode In special mode, COP is disabled after reset and the CPU can be stopped immediately after reset by the debugger. After the CPU enters in the active BDM mode for the first time, the debugger writes to the COPCTL register. The COPCTL value from the Advanced dialog is written and RSBCK bit set. The user must enter the COPCTL value used in the application in the Advanced dialog. Since COPCTL register is write any time in special mode, the application must set RSBCK bit too when writing to the COPCTL register. Unsecure Flash HCS12 family features mechanism, which locks BDM if the flash is secured. This mechanism was built into the CPU to prevent memory read over the BDM by unauthorized person and thus protecting the code (intellectual property) in the internal flash. Secured flash can be unsecured by BDM debugger, which executes special unlocking sequence. Note that FLASH is erased when it s unsecured. There is no way to read the code from the internal flash after it s secured. Flash is unsecured by pressing the 'Unsecure FLASH' button in the Hardware/Hardware Tools/HCS12 tab. Flash is secured by pressing the 'Secure FLASH' button after the value of FSEC FLASH Secure register is specified. After the FLASH is secured, BDM is locked and not operational after next CPU reset. 15

Target Reset Beside the debugger, the target can have additional external reset sources, like power-on reset, watchdog circuitry or even reset push-button. In general, it s recommended to disable all external reset sources in the target, which may disturb the debugger in a way that BDM communication is lost and complete system needs to be reinitialized. It s recommended that all reset sources are designed as an open drain type. Reset From Target Enabled option in the CPU Setup/Options tab must be normally checked to assure safer debugging. Then the debugger can detect any reset source and service it properly. Since target reset lines are designed as an open drain type, the debugger can detect all resets, even if they have been initiated by a hardware other than the emulator itself. In certain applications though, the requirement to disable this type of checking is required. When the CPU operates in an environment with interferences, it s recommended to add a capacitor to the target reset line. In order for the CPU to be able to initiate a reset and then to differentiate among the 'internal' and 'external target' reset (the length of less than 8 ECLK cycles), the capacitor must be relatively small. However, the interference can be in some cases so big that a bigger capacitor must be used. In such case, the debugger does not function correctly, if reset from the target is not disabled. 16

To disable detecting reset sources from the target by the debugger, the RESET From Target Enabled option must be unchecked. Note: Wrong setting of this option can significantly change the operation of the target! The reset line from the debugger can be driven as an open drain or as push-pull line. Typically, open drain reset signals are used, but in special cases, push-pull signals are preferred. A special case is, if a large capacitor is located on the reset line because of interference. Next case is, if the target contains an external watchdog that cannot be disabled. During the debugging phase, it must somehow be disabled. In this case, the watchdog line should be connected to the CPU reset line through a serial resistor (for example 1k). If the emulator s reset line is connected directly to the CPU reset line and its type is push pull, then the watchdog can no longer reset the CPU by itself. Note: Wrong setting of this option can significantly change the operation of the target! 17

Hot Attach Operation HCS12 BDM allows attachment to a running target system without affecting its operation. Such operation is called Hot Attach. It s assumed that there is a running target with no debugger connected. To hot attach: Check the Hot attach to target option in the Hardware/Emulation Options/Hardware tab. Execute Download debug command. Connect the BDM cable to the target system Select the 'Attach' debug command in the Debug menu to attach to the target system. Now, the debugger should display run status and the application can be stopped and debugged if necessary. Select 'Detach' debug command in the Debug menu to disconnect from the target application. If the CPU was stopped before detach, it will be set to running. When running with Hot Attach, make sure that your program sets the RSBCK bit of the COPCTL register if the application is using COP. This way, the COP counter is disabled when the CPU is stopped. 18

Getting Started Before starting configuring the development system, please read the Technical Notes/BDM Emulation/Motorola 68HC12 chapter in the hardware user s guide (part of winidea on-line help). Debug Connection It s assumed that the emulator is not connected to the target yet and that both the target and the emulator are switched off. Install and start winidea application. Make sure you have current winidea version before installing it. Connect the emulator to the PC where winidea is installed. Supply the power to the emulator and switch it on. Select Hardware by selecting Hardware/Hardware. Select Communication tab within the same dialog and select the communication type that is going to be used. Refer to Setting Up Communication document (delivered beside the emulator) for more details on how to configure each of the supported communications. 19

Execute communication test by pressing Test button. There must be no packets with errors reported during the communication test. Next, switch off the emulator and proceed with the configuration. Select On-Chip (BDM, JTAG, ) debugging type. Select the CPU family, the icard and the CPU in the Hardware/Emulation Options dialog. 20

Make sure that the Hot attach to target option is unchecked in the Hardware/Emulation Options/Hardware tab. Set CPU clock frequency in the Hardware/Emulation Options/CPU/CPU Setup/Clock tab that your target uses. Note that the BDM protocol operates synchronously to the CPU clock. Select Special Mode in the Advanced tab for the operating mode. Select the Debug I/O levels in the Hardware/Emulation Options dialog. The development tool can drive debug BDM signals at 5, 3.3V or target Vcc level. Set proper Debug I/O levels depending on the target CPU. Most HCS12 CPUs have 5V I/Os, however for instance MC9S12NE64 has 3.3V I/Os. Normally, these are the minimum settings required by the emulator to be able to connect to the target CPU. Verify if the BDM connector in the target matches with the pinout defined by the CPU vendor. The required connector pinout can be also found in the hardware reference document delivered beside the debug icard. Connect the emulator to the target. 21

First power on the emulator and then the target! On power off, first the target needs to be switched off and then the emulator. Otherwise damage to the hardware may occur! Close all debug windows in winidea except for the disassembly window. Execute debug CPU Reset command. WinIDEA should display STOP status and disassembly window should display the code around the address where the program counter points to. If that s the case, the debugger is operational. You can inspect special function registers in the SFR window or read and modify (RAM) memory in the memory window. Troubleshooting If the debug CPU Reset command fails, verify: BDM cable, target BDM connector pinout and connection with the target clock frequency in your target and a frequency specified in winidea physical clock signal Measure EXTAL clock signal with oscilloscope. It may happen that the crystal doesn t oscillate. reset line of your target There should be no other reset sources, which could disturb BDM communication. Remove all capacitors and other reset logic from the reset line and try again. Make sure that the RESET from target enabled option is checked in the CPU Setup/Options tab. Next step is to download the program or more precisely to program the CPU internal flash. FLASH Programming A file that has to be programmed must be added in the Debug/Files For Download/Debug Files tab and Use Debug download files option checked in the FLASH/Setup /Target tab. winidea expects bank addresses in the download file by default. It s recommended that the project is compiled in a way that the download file contains bank addresses. If that's not possible and the file contains for instance linear addresses, the user must force linear memory space by selecting Linear in the Memory area combo box when specifying the download file. Wrong addressing can result in download errors. The 'Enabled' option in the Hardware/Emulation Options/CPU Setup/Memory Expansion tab must be checked if the code is linked for a bank application. It must be unchecked, if it s a non-bank project. Open FLASH Programming Setup dialog from FLASH/Setup menu. Press Hardware Setup button in the Target tab and select programming through flash monitor. Open FLASH Program dialog from FLASH/Program menu and press Start button. Now, the FLASH should be programmed. Troubleshooting If FLASH programming fails, verify if: proper CPU is selected Hot Attach option is unchecked Try to program another CPU too. It s possible that FLASH was already programmed more times than specified and it s unusable. Debugging Execute Download debug command. 22

The program should be stopped. Set a breakpoint on main and run the application. It should hit the breakpoint. Next, try to step in the disassembly window first and then in the source window. Next, run the application and then set a breakpoint in the program, which is executed. The program should stop at the breakpoint. Troubleshooting If any of the above tests fail, please Read Debugging application using PLL section. Read Debugging application using COP section. Read Target Reset section. Double-check the BDM connection. Try to press the BDM connector in the target with fingers to establish better connection and to eliminate possible source of the problem. Troubleshooting Please, visit below link to find out the most recent known issues and troubleshooting hints: http://www.asystelectronic.si/isystem/faq/ Disclaimer: isystem assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information herein. isystem May 2005. All rights reserved. 23

Notes: 24