Chapter 3 HCS12 Members and Hardware and Software Development Tools.

Slides:



Advertisements
Similar presentations
Getting started with MPLAB Launch MPLAB Set Toolbar as in the next slide by clicking the leftmost icon Open a new Source file by choosing [FILE][NEW] Type.
Advertisements

Introduction to HT-IDE3000 Micro-C development System Department.
Code Composer Department of Electrical and Computer Engineering
The 8051 Microcontroller and Embedded Systems
Professional Toolkit V2.0 C:\Presentations - SmartCafe_Prof_V2.0 - bsc page 1 Professional Toolkit 2.0.
MC68HC11 System Overview. System block diagram (A8 version)
Chapter 2 Machine Language.
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Lab6 – Debug Assembly Language Lab
The 68HC11 Microcontroller Minnesota State University, Mankato
Chapter 2 Machine Language. Machine language The only language a computer can understand directly. Each type of computer has its own unique machine language.
Introduction to Microprocessors Number Systems and Conversions No /6/00 Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
1 Color Discriminating Tracking System Lloyd Rochester Sam Duncan Ben Schulz Fernando Valentiner.
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
EET 2261 Unit 2 HCS12 Architecture
ECE Department: University of Massachusetts, Amherst Lab 1: Introduction to NIOS II Hardware Development.
Microcontroller Architecture— PIC18F Family
© 2010 Kettering University, All rights reserved..
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
Introduction Purpose Objectives Content Learning Time
Cortex-M3 Debugging System
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.
Atmega32 Architectural Overview
Chapter 2 Software Tools and Assembly Language Syntax.
Silicon Labs ToolStick Development Platform
Curriculum Development for ENGR 290 Introduction to Microcontroller
The 6713 DSP Starter Kit (DSK) is a low-cost platform which lets customers evaluate and develop applications for the Texas Instruments C67X DSP family.
Chapter Introduction to Computers and Programming 1.
EE 362 Microprocessor Systems and Interfacing © 2-1 Laboratory 2.1 Part 1: Assembler Directives Procedure:  Create a directory called H:\cx\source\ee362\lec02\L02LabAld.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
NetBurner MOD 5282 Network Development Kit MCF 5282 Integrated ColdFire 32 bit Microcontoller 2 DB-9 connectors for serial I/O supports: RS-232, RS-485,
Introduction Purpose This training course covers debugging an application on an SH target in the Renesas HEW (High-performance Embedded Workshop) development.
P.1ECE 331, Prof. A. Mason Professor Andrew Mason Michigan State University Spring 2013 ECE 331: PC Lab 1: Using HC12 ASM Simulators.
ADAM46P20 Simulator V User’s Manual ETA Chips, Co., Kr., 2011 By W.S.YOU.
Revised: Aug 1, ECE 263 Embedded System Design Lesson 1 68HC12 Overview.
AT91RM9200 Boot strategies This training module describes the boot strategies on the AT91RM9200 including the internal Boot ROM and the U-Boot program.
Physics 413 Chapter 1: Introduction to the HCS 12 Microcontroller.
ADAM2 Single Remocon MCU IDE User’s Manual S/W Integrated Development Environment - Assembler - Simulator - Code Wizard V1.0 Technical Sales Team, ETA.
UBI >> Contents Chapter 2 Software Development tools Code Composer Essentials v3: Code Debugging Texas Instruments Incorporated University of Beira Interior.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Presented by Sadhish Prabhu
ChibiOS/RT Demo A free embedded RTOS
Features of the PIC18 microcontroller - 8-bit CPU - 2 MB program memory space (internal 32KB to 128KB) bytes to 1KB of data EEPROM - Up to 4096 bytes.
Chapter – 8 Software Tools.
Chapter Microcontroller
HCS12 Technical Training Module 15 – Break Module Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Components of a typical full-featured microcontroller.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
EE345 Chapter 2 Lecture 3 April 4. Quiz every Wednesday 1 quiz = 1% extra credit five quizzes before midterm  5% for midterm. five quizzes before final.
Programming and Debugging with the Dragon and JTAG Many thanks to Dr. James Hawthorne for evaluating the Dragon system and providing the core content for.
CEng3361/18 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2007 Recitation 01.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
INTRODUCTION TO AVRASSEMBLY PROGRAMMING
ECE 3430 – Intro to Microcomputer Systems
Programming and Debugging with the Dragon and JTAG
HCS12 Exceptions Maskable Interrupts
Fundamentals of Computer Engineering
Atmega32 Architectural Overview
Microcontroller Applications
DIGITAL CALCULATOR USING 8051
Introduction to Microprocessors and Microcontrollers
AT91RM9200 Boot strategies This training module describes the boot strategies on the AT91RM9200 including the internal Boot ROM and the U-Boot program.
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Building an SBC-51 The Single Board Computer SBC-51 is a simple 8051 platform for learning and experimenting with the hardware and software development.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Software Setup & Validation
8051 ASSEMBLY LANGUAGE PROGRAMMING
Presentation transcript:

Chapter 3 HCS12 Members and Hardware and Software Development Tools

- The HCS12 Members (1 of 2) Is a redesign of the 68HC12 family The 68HC12 family is an upgrade of the popular 68HC11 8-bit microcontroller family. The 68HC12 has a highest bus clock frequency of 8 MHz. The HCS12 family has a highest bus clock frequency of 32 MHz. The numbering system is shown in Figure 3.1.

- The HCS12 was initially designed for automotive and process control market. The HCS12 has many features designed for these target markets: –Parallel ports –Timer functions: input capture, output compare, pulse accumulation, real- time interrupt, pulse width modulation, modulus down counter –Serial communication interface (SCI) –Serial peripheral interface (SPI) –Inter-integrated circuit (I2C) –Byte data link control (BDLC) –Controller Area Network (CAN) Freescale also included the background debug mode (BDM) in each HCS12 member to facilitate the software debugging activities. Freescale also include special features to target other applications: –Ethernet controller: the MC9S12NE64 has an Ethernet controller to facilitate the access of the Internet. –USB controller: the MC9S12UF32 has an on-chip USB controller to facilitate the interfacing with USB bus. The HCS12 Members (2 of 2)

Development Tools Software development tools –Text editor, terminal program, cross assembler, cross compiler, simulator, source-level debugger, integrated development environment (IDE) Hardware development tools –Oscilloscope, function generator, in-circuit emulator, logic analyzer, demo board Only demo boards and BDM kit will be discussed.

Software Development Tools A text editor allows the user to enter and edit the program. A cross assembler allows the user to assemble their assembly programs. A cross compiler allows the user to compile their programs written in high-level languages. A simulator allows the user to run the application program without having the actual hardware. A terminal program allows the PC to communicate with the hardware demo board. A source-level debugger allows the user to set breakpoints in the program, trace program execution, watch program variable values after program execution, and so on. An IDE combines all of the above programs in one package so the user can perform all software debugging activities in one environment without quitting any program. –The freeware miniIDE and asmIDE are recommended for assembly program development. –The freeware EmbeddedGNU IDE and GNU C compiler are recommended for C program development.

Demo Boards Many HCS12-based demo boards are available for learning the HCS12 and debugging the HCS12 application programs. A demo board has an HCS12 MCU and many peripheral chips to help test the HCS12 programs. A demo board often has an on-board monitor program to communicate with a PC or workstation on which the user develops the application program. The monitor program allows the user to display register and memory location contents, setting register and memory location contents, setting program breakpoints, tracing instruction execution, and download programs onto the demo board for execution. The PC or workstation communicates with the demo board using the terminal program. The SSE256 from Shuan Shizu and the Dragon12 from Wytec are recommended for learning the HCS12 microcontroller.

The Dragon12 Demo Board (1 of 2) 24-MHz bus speed (generated from a 4-MHz crystal) D-Bug12 monitor 16 x 2 LCD kit (4-bit interface) Eight LEDs Four seven-segment displays Keypad connector Four buttons for input DIP switches for input Buzzer for playing siren and songs (wired to the PT5 pin) Potentiometer for testing A/D function (wired to PAD7 pin) Infrared transceiver CAN transceiver (Philips PCA82C250) A small breadboard BDM IN and BDM OUT connectors Two RS232 connectors LTC bit D/A converter chip with SPI interface 24LC16 serial EEPROM with I2C interface Additional information is available at

The Dragon12 Demo Board (2 of 2)

The SSE256 Demo Board (1 of 2) 24-MHz bus speed (generated from a 16-MHz oscillator) D-Bug12 monitor 20 x 2 LCD kit (8-bit interface) Eight LEDs Four seven-segment displays Function generator with square waveform output, 24 frequency outputs ranging from 1 Hz up to 16 MHz (half of the them are in power of 2) DIP switches for data input Keypad connector Four debounced switches for input with interrupt capability DS1307 real-time clock chip with I2C interface 24LC08 serial EEPROM with I2C interface TC72 digital thermometer with SPI interface TLV bit D/A converter with SPI interface Buzzer for playing siren and songs (can be driven by any output input) Potentiometer for testing A/D function (wired to the PAD7 pin) CAN transceiver (MCP2551) BDM IN and BDM OUT connectors Two RS232 connectors Additional information available at

The SSE256 Demo Board (2 of 2)

The D-Bug12 Monitor Supports most HCS12 devices with 128KB and 256 KB flash memory Used in many demo boards Requires a host terminal program that supports the Xon/Xoff software handshake for proper operation The HyperTerminal bundled with Windows and the terminal program bundled with asmIDE, miniIDE, and EmbeddedGNU IDE can work with D-Bug12 monitor. Supports four operating modes: EVB mode, Jump to EEPROM mode, POD mode, and Serial Bootloader mode After reset, the D-Bug12 reads the logic levels on the PAD1 and PAD0 pins to decide which of the four D-Bug12 modes to enter.

- When the demo board is powered up and the baud rate is set properly, the message as shown to the right will appear on the terminal screen. EVB Mode The D-Bug12 monitor operates from the flash memory The users are restricted to use SRAM (from $1000 to $3BFF) or EEPROM to run application programs. The user runs a terminal program on the PC to communicate with the D-Bug12 monitor on the demo board. EVB operation model is shown below.

The D-Bug12 monitor displays the “>” character to indicate it is ready for operation. When a command issued to D-Bug12 is successfully executed, the monitor displays the execution result and a new > character on a new line. If a command is not successfully executed, press the reset button to get out. An alternative to get out of the unsuccessful command is to press the abort key. The abort key is connected to the XIRQ signal. Both the SSE256 and Dragon12 demo boards use the MC9S12DP256 as their MCU. The memory maps for these two demo boards are shown below.

Using the MiniIDE (1 of 18) Step 1. Invoke the MiniIDE by double clicking the icon of MiniIDE. Step 2. Communicating with the demo board –Press the Terminal menu (shown in Figure C.2) and select Show Terminal Window. –Press the reset button on the demo board and the screen will change to Figure C.3.

Using the MiniIDE (2 of 18)

Using the MiniIDE (3 of 18)

Step 3. Setting options -Set Options can be found under the Build menu and Terminal menu. Using the MiniIDE (4 of 18)

Using the MiniIDE (5 of 18)

Using the MiniIDE (6 of 18) Options in General category

Using the MiniIDE (7 of 18) Options in Terminal category

Using the MiniIDE (8 of 18) Options in Tool category

Using the MiniIDE (9 of 18) Options in Assembler category

Using the MiniIDE (10 of 18) Step 4. Open a new file for entering an assembler program. –Press the File menu and select New and the screen is changed to Figure C.10. –Enter the program as shown in Figure C.11. –Save the file after the whole program is entered. Press the File menu and select Save as shown.

Using the MiniIDE (11 of 18)

Using the MiniIDE (12 of 18)

Using the MiniIDE (13 of 18) Step 5. Assemble the program. –Press the Build menu and select Build siren.asm as shown. –After a successful assembly, the status window will display the corresponding message as shown.

Using the MiniIDE (14 of 18)

Using the MiniIDE (15 of 18) Step 6. Download the program onto the demo board. –Type the load command followed by the enter key in the terminal window. –Press the Terminal menu and select Download File (shown in Figure C.15). –A dialog box as shown in Figure C.16 appears. –Enter the name of the file to be downloaded and click on Open. –After a successful download, the screen is changed to Figure C.17.

Using the MiniIDE (16 of 18)

Using the MiniIDE (17 of 18)

Using the MiniIDE (18 of 18) Step 7. Running and debugging the program –Type g 2000 followed by enter key. –This program will generate a two-tone siren.

Using the D-Bug12 Commands - BF [ ] Fill a block of memory locations with the value of. To fill the memory locations from $1000 to $1FFF with 0, enter the following command: >bf FFF 0 - MD [ ] Display memory contents from to. 16 bytes are displayed on each line. The is rounded down to the next lower multiple of 16. The is rounded up to the next higher multiple of 16. Only one line is displayed if the EndAddress is not specified.

>md AA C - D7 98 9A 61 - DF BE BC E AE D0 3D a = >md AA C - D7 98 9A 61 - DF BE BC E AE D0 3D a = DA DF F 34 BD A9 - 2A CA FA DB - AC DA u..9?4..* D 5B 48 BA - B2 F7 B6 1B E5 E4 - A5 E9 01 9F M[H > MDW [ ] >mdw AA85 060C - D798 9A61 - DFBE BCE9 - 03AE D03D a = >mdw AA85 060C - D798 9A61 - DFBE BCE9 - 03AE D03D a = DA DF39 - 3F34 BDA9 - 2ACA FADB - ACDA 1897 u..9?4..* D5B 48BA - B2F7 B61B E5E4 - A5E9 019F M[H >

MM [ ] Used to examine and modify the contents of memory locations one byte at a time. If the 8-bit data parameter is present on the command line, the byte at memory location is replaced with and the command is terminated. –If no data is provided, then D-Bug12 enters the interactive memory modify mode. –In the interactive mode, each byte is displayed on a separate line following the address of data. –Single-character sub-commands are used for the modification and verification of memory contents in interactive mode. –The available sub-commands are as follows: [ ] Optionally update current location and display the next location. [ ] or Optionally update current location and redisplay the same location. [ ] or Optionally update current location and display the previous location. [ ] Optionally update current location and exit Memory Modify.

>mm FF ^ 1001 FF / > MMW [ ] -Allows the contents of memory to be examined and/or modified as 16-bit hex data. -If the 16-bit data is present on the command line, the word at memory location is replaced with and the command is terminated. -If no data is provided, then D-Bug12 enters the interactive memory modify mode. -MMW supports the same set of sub-commands as does the MM command.

>mmw F AA ^ aabb > Move -The number of bytes moved is one more than - >move ff 1100 > RD – register display >rd PP PC SP X Y D = A:B CCR = SXHI NZVC C E: xx:1521 9C42 CPD $0042 >

RM – register modification >rm PC= SP=0A00 IX= IY=0000 A=00 B=00 ff CCR=90 d1 PC=1500. > -Allow one to change the value of any CPU register. -Each bit of the CCR register can be changed by specifying its name.

>pc 2000 PC SP X Y D = A:B CCR = SXHI NZVC A :FF >x 800 PC SP X Y D = A:B CCR = SXHI NZVC A :FF >c 0 PC SP X Y D = A:B CCR = SXHI NZVC A :FF >z 1 PC SP X Y D = A:B CCR = SXHI NZVC A :FF >d 2010 PC SP X Y D = A:B CCR = SXHI NZVC A : >

Invokes the one-line assembler/disassembler. Allows memory contents to be viewed and altered using assembly language mnemonics. When displaying instructions, each instruction is displayed in its mnemonic form. The assembly/disassembly process can be terminated by a period. The one-line assembler displays the current instruction and allows the user to enter new instruction. User can skip the current instruction by pressing the Enter key. ASM (1 of 2)

The following example displays instruction starting from $2000: >asm FC0800 LDD $0800 > 2003 CD0900 LDY #$0900 > 2006 CE000A LDX #$000A > IDIV > 200B CB30 ADDB #$30 > 200D 6B44 STAB 4,Y > 200F B7C5 XGDX > 2011 CE000A LDX #$000A >. > The following example enters three instructions (in bold face) starting from $1500: >asm FC0800 LDD $ F30802 ADDD $ C0900 STD $ E78C TST 12,SP >. > ASM (2 of 2)

>br ; set three breakpoints Breakpoints: >br; display current breakpoints Breakpoints: > BR [ …] Setting or Examine Breakpoints A breakpoint halts the program execution when the CPU reaches the breakpoint address. When a breakpoint is encountered, the D-Bug12 monitor displays the contents of CPU registers and the instruction at the breakpoint (not executed yet). Breakpoints are set by typing the breakpoint command followed by one or more breakpoint addresses. Entering the breakpoint command without any breakpoint addresses will display all the currently set breakpoints. A maximum of ten user breakpoints may be set at one time.

>br ; set four breakpoints Breakpoints: >nobr ; delete two breakpoints Breakpoints: >nobr; delete all breakpoints All Breakpoints Removed > NOBR [ ] Delete one or more previously defined breakpoints. All breakpoints will be deleted if no addresses are specified.

>g 1500 User Bkpt Encountered PP PC SP X Y D = A:B CCR = SXHI NZVC C 3C00 7B :E xx:150C 911E CMPA $001E > G [ ] Begin execution of user code at the specified address. If no address is specified, CPU starts execution of the instruction at the current PC address.

>pc 1500 PP PC SP X Y D = A:B CCR = SXHI NZVC C : xx:1500 CF1500 LDS #$1500 >gt 1540 Temporary Breakpoint Encountered PP PC SP X Y D = A:B CCR = SXHI NZVC E: xx:1510 3B PSHD > GT Execute instruction until the given address and stop. User usually needs to specify where the program execution should start before issuing this command.

>pc 1500 PP PC SP X Y D = A:B CCR = SXHI NZVC E: xx:1500 CF1500 LDS #$1500 >t PP PC SP X Y D = A:B CCR = SXHI NZVC E: xx:1503 CE1000 LDX #$1000 >t 2 PP PC SP X Y D = A:B CCR = SXHI NZVC E: xx: PSHX PP PC SP X Y D = A:B CCR = SXHI NZVC FE E: xx: E LDAA #$1E > T [ ] Used to execute one or multiple instructions starting from the current PC address. As each program instruction is executed, the CPU register contents and the next instruction to be executed are displayed. Only one instruction will be executed when no count is specified.

>call 1600 Subroutine Call Returned pp PC SP X Y D = A:B CCR = SXHI NZVC A : xx:1600 FC1000 LDD $1000 > CALL [ ] Used to execute a subroutine and returns to the D-Bug12 monitor program. All CPU registers contain the values at the time the final RTS instruction was executed, with the exception of the program counter. The program counter contains the starting address of the subroutine when returning from the subroutine.

The Pod Mode This mode is intended to run the demo board as a BDM host to control a target board. –Arrangement shown below

The Jump-to-EEPROM Mode Execute a small program from the on-chip EEPROM whenever the EVB is powered up or reset. This mode provides a way to execute a program in a standalone manner without having to erase and program the on-chip flash memory using the bootloader.

The Bootloader Mode The Bootloader resides from $F000 to $FFFF. Bootloader can be used to erase and reprogram the remainder of on- chip flash memory or erase the on-chip EEPROM. Bootloader utilizes the SCI port for communication. The only required host program is a terminal program that can communicate at 9600 to 115,200 baud and supports XON/XOFF handshaking. The bootloader mode prompt is as follows:

Tips for Assembly Program Debugging Syntax errors –Misspelling of instruction mnemonics Starting instruction mnemonic at column 1. The mnemonic is treated as a label whereas the operands are treated as mnemonic. –Missing operands Will be highlighted by the assembler and are easy to fix. Logic errors –Using extended (or direct) mode instead of immediate mode A program with this type of addressing mode error is on the next page.

Nequ20; array count org$1000 arraydc.b2,4,6,8,10,12,14,16,18,20 dc.b22,24,26,28,30,32,34,36,38,40 sumds.w1 org$1500 ldxarray; place the starting address of array in X movw0,sum; initialize sum to 0 ldyN; initialize loop count to N loopldab1,x+; place one number in B and move array pointer sexB,D; sign-extend the 8-bit number to 16-bit adddsum; add to sum stdsum; update the sum dbney,loop; add all numbers to sum yet? swi; return to monitor end - Assemble and download this program onto the demo board. >load.... done >

Use the asm command to make sure that the program is downloaded correctly. >asm 1500 xx:1500 FE1000 LDX $1000 > xx: MOVW $0000,$1014 > xx:1509 DD14 LDY $0014 > xx:150B E630 LDAB 1,X+ > xx:150D B714 SEX B,D > xx:150F F31014 ADDD $1014 > xx:1512 7C1014 STD $1014 > xx: F3 DBNE Y,$150B > xx:1518 3F SWI >. Make sure that program data is downloaded correctly. Use the md command: >md A 0C 0E A 1C 1E B9 A9 - 2A CA FA DB - AC DA "$&(....* >

>g 1500 User Bkpt Encountered PP PC SP X Y D = A:B CCR = SXHI NZVC C FF: xx: F4 EORA #$F4 > Exam the execution result – incorrect!! >md FF 07 B9 A9 - 2A CA FA DB - AC DA > The program is short. Errors can be found by tracing. Set PC to the start of the program (at $1500) >pc 1500 PP PC SP X Y D = A:B CCR = SXHI NZVC C FF: xx:1500 FE1000 LDX $1000 > Run the Program

>t 1 PP PC SP X Y D = A:B CCR = SXHI NZVC C FF: xx: MOVW $0000,$1014 > The executed instruction is “ldx $1000” which should place the start address of the array in X. The instruction trace result shows that X receives $0104, not $1000. This is due to addressing mode error. Change the instruction to ldx #$1000 and rerun the program. Reload the program and trace the program. Trace two instructions this time. Trace One Instruction at a Time

>t 2 PP PC SP X Y D = A:B CCR = SXHI NZVC C FF:F xx: MOVW $0000,$1014 PP PC SP X Y D = A:B CCR = SXHI NZVC C FF:F xx:1509 DD14 LDY $0014 >md 1010; examine sum at $1014~$ FF 00 B9 A9 - 2A CA FA DB - AC DA > We expect the variable sum (at $1014 and $1015) to receive $0000. But it didn’t. The error is again caused by incorrect use of the addressing mode. The movm 0,sum instruction copies the contents of memory location 0 to sum. Change the second instruction to movw #0,sum. Rerun the program and examine the memory contents. It is still incorrect !!

>load * >g 1500 User Bkpt Encountered PP PC SP X Y D = A:B CCR = SXHI NZVC C00 100F :F xx: F4 EORA #$F4 >md F0 B9 A9 - 2A CA FA DB - AC DA > Trace the program up to the third instruction:

>pc 1500 PP PC SP X Y D = A:B CCR = SXHI NZVC C00 100F :F xx:1500 CE1000 LDX #$1000 ; 1 st instruction >t 3 PP PC SP X Y D = A:B CCR = SXHI NZVC C :F xx: MOVW #$0000,$1014 ; 2 nd instruction PP PC SP X Y D = A:B CCR = SXHI NZVC C :F xx:1509 DD14 LDY $0014 ; 3 rd instruction PP PC SP X Y D = A:B CCR = SXHI NZVC B 3C F 00:F xx:150B E630 LDAB 1,X+ > The program intends to load 20 into Y with the third instruction and expect Y to be set to 20. But Y did not get 20. It receives F instead. This is due to the incorrect use of the addressing mode. Change the instruction to ldy #20 and rerun the program.

>g 1500 User Bkpt Encountered PP PC SP X Y D = A:B CCR = SXHI NZVC A 3C :A xx:151A F421BD ANDB $21BD >md A4 B9 A9 - 2A CA FA DB - AC DA > After this correction, sum receives the correct value $1A4 (420).

Example Program – Finding the sum of elements of an array Nequ20; array count org$1000 arraydc.b2,4,6,8,10,12,14,16,18,20 dc.b22,24,26,28,30,32,34,36,38,40 sumds.w1 org$1500 ldx#array; place the starting address of array in X movw#0,sum; initialize sum to 0 ldy#N; initialize loop count to N loopldd1,x+; place one number in D and move array pointer adddsum; add to sum stdsum; update the sum dbney,loop; add all numbers to sum yet? swi; return to monitor end Mismatch of Operand Size

The value of sum is incorrect after running the program: >md A6 1F B9 A9 - 2A CA FA DB - AC DA > This program can be debugged by tracing: >pc 1500 PP PC SP X Y D = A:B CCR = SXHI NZVC C A6:1F xx:1500 CE1000 LDX #$1000 >t PP PC SP X Y D = A:B CCR = SXHI NZVC C A6:1F xx: MOVW #$0000,$1014 >t PP PC SP X Y D = A:B CCR = SXHI NZVC C A6:1F xx:1509 CD0014 LDY #$0014 >t PP PC SP X Y D = A:B CCR = SXHI NZVC C 3C A6:1F xx:150C EC30 LDD 1,X+

>t PP PC SP X Y D = A:B CCR = SXHI NZVC E 3C : xx:150E F31014 ADDD $1014 > The 4th instruction should place the value 2 in D rather than $0204. This is due to the incorrect use of the instruction of ldd 1,x+. This instruction should be replaced by the following two instructions: ldab 1,x+ clra Other logic errors: Inappropriate Use of Index Addressing Mode Indexed addressing mode is often used to step through array elements. After accessing each element, the index register must be incremented or decremented. Program execution can’t be correct if index register is incremented or decremented incorrectly. This error can be found after performing computation in the first one or two elements by program tracing.

Stack Frame Errors This error will be discussed in Chapter 4.

Incorrect Algorithm This type of error can be detected by tracing the program. –The user needs to read the program carefully in order to find out the errors.

BDM-based Source Level Debuggers BDM module allows the host to access the resources of the target using a single pin. The BDM mode allows the tool vendor to design inexpensive source- level debuggers. –The hardware to support source-level debugging can be very inexpensive. –The hardware is often called a pod (or BDM kit). The simplest BDM kit is a very simple HCS12 demo board with a resident D- Bug12 monitor and configured to operate in the POD mode. –The tool vendor needs to provide a PC-based software to issue commands to the BDM kit to access the resources (registers and memory locations) of the target hardware. –The PC-based software provides a user friendly interface and allows the user to set breakpoint, display and modify registers and memory locations, set up a watch list, trace program execution, and so on. The simplest BDM kit needs only a terminal program to be run on the PC. The Wytec DragonBDM kit has no PC-based software to provide source-level debugging.

Functions of DragonBDM Kit Allows the user to program application programs into the target MCU Allows the user to use all D-Bug12 commands to perform debugging on the target hardware The target hardware does not need to have any resident monitor program Very affordable Allows users to develop product using many inexpensive HCS12C32 kits on the market.