AN2548 Freescale Semiconductor / Motorola, AN2548 Datasheet

no-image

AN2548

Manufacturer Part Number
AN2548
Description
Serial Monitor Program for HCS12 MCUs
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
AN2548/D
9/2003
Serial Monitor Program for
HCS12 MCUs
By Jim Williams
Introduction
The products described in this document incorporate SuperFlash
Windows
8/16 Bit Applications Engineering
Austin, Texas
is a registered trademark of Microsoft Corporation in the U.S. and/or other countries.
This application note describes a 2-Kbyte monitor program for the HCS12
series MCU. This program supports 23 primitive debug commands that allow
FLASH/EEPROM programming and debugging through an RS-232 serial
interface to a personal computer. The monitor supports primitive commands to
reset the target MCU, read, or modify memory (including FLASH/EEPROM
memory), read or modify CPU registers, GO, HALT, or TRACE single
instructions. To allow a user to specify the address of each interrupt service
routine, this monitor redirects interrupt vectors to an unprotected portion of
FLASH just before the protected monitor program. This monitor is intended to
be generic, so this single application (with very slight modification) should
execute on any HCS12 derivative.
Using this monitor program provides users with a cost-effective method to
evaluate their MCUs by writing programs, programming them into the MCU,
then debugging their applications for the HCS12 MCU — using only a serial I/O
cable and free software on their personal computer. The monitor does not use
any RAM other than the stack itself. Because the monitor uses the COP
watchdog for a cold reset function, user code should not enable or disable the
COP function (by writing to COPCTL). This development environment
assumes that the user resets to the monitor when performing debug
operations. If user code takes control directly from reset, and then an SCI0
interrupt or a SWI attempts to enter the monitor, the monitor may not function
because SCI0, the phase-locked loop (PLL), and memory initialization
registers may not be initialized as they would be for a cold reset into the
monitor.
There is no error handling for the PLL. If the frequency source is missing or
broken, the monitor will not function. Through the use of equate definitions, the
monitor sets the operating speed of the MCU to 24 MHz. User modification of
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
technology licensed from SST.
© Motorola, Inc., 2003

Related parts for AN2548

AN2548 Summary of contents

Page 1

... Freescale Semiconductor, Inc. Application Note AN2548/D 9/2003 Serial Monitor Program for HCS12 MCUs By Jim Williams 8/16 Bit Applications Engineering Austin, Texas Introduction This application note describes a 2-Kbyte monitor program for the HCS12 series MCU. This program supports 23 primitive debug commands that allow FLASH/EEPROM programming and debugging through an RS-232 serial interface to a personal computer ...

Page 2

... Freescale Semiconductor, Inc. AN2548/D the MCU speed without consideration for the monitor program will render the monitor nonfunctional. If the PLL loses lock during operation, the monitor will fail. NOTE: With the exception of mask set errata documents, if any other Motorola document contains information that conflicts with the information in the device guide, the device guide should be considered to have the most current and correct data ...

Page 3

... EEPROM (if the target device has any) is limited to the available space between the registers and the RAM ($0400–to start of RAM). External devices attached to the multiplexed external bus interface are not supported. Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Memory Configuration 3 ...

Page 4

... Freescale Semiconductor, Inc. AN2548/D ensure that a Windows communications with the monitor, the host must send a carriage return ($0D) at the correct baud rate. If the monitor detects some other character, the host baud rate is not correct so it continues to wait in a loop for the $0D character before printing the first prompt sequence ...

Page 5

... A and B accumulators The 16-bit end address for an erase or block command IDID The 2-byte device ID from PARTID register IX The contents of the 16-bit X index register IY The contents of the 16-bit Y index register Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Run/Load Switch Definition 5 ...

Page 6

... Freescale Semiconductor, Inc. AN2548/D Table 1. Abbreviations Used in Command Sequences (Continued) Abbreviation RDW RDB RDB (AAAA+1) RDB SADR (AAAA+1) WB (AAAA+NN) Some monitor commands such as Read_Byte and Write_Byte can be executed at any time while others may be executed only while the monitor is active and waiting for commands (as opposed to while running user code). ...

Page 7

... Intelligent Writes for details. error and the write data will be ignored. /RDB /.../RDB (AAAA) (AAAA+1) Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Monitor Commands $E2 — error and $0000 data. Intelligent Writes $E2 — Command Not — Reads a series of NN+1 (1 (AAAA+NN) for ...

Page 8

... Freescale Semiconductor, Inc. AN2548/D $A8 — Write_Block A8/AAAA/NN/WB 256) bytes of data into the target MCU memory starting at address AAAA and ending with address AAAA+NN. This routine assumes that accesses to the paged memory area have been preceded by a PPAGE register access (Write_Byte 0030 = page) to select the appropriate page ...

Page 9

... For More Information On This Product, Writes the specified 16-bit data to accumulator A and accumulator B — Writes the specified 8-bit data to the condition codes register (CCR) — The monitor sets up the on-chip breakpoint or debug module to force a Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Monitor Commands 9 ...

Page 10

... Freescale Semiconductor, Inc. AN2548/D $B4 — Reset B4 — When a user reset vector is programmed, the levels on the run/load switch and the RxD0 line could cause a reset to either the user code or the monitor. The sequence of checks to determine the type of reset is listed and illustrated the first byte of the user reset pseudo-vector = $FF 2 ...

Page 11

... Therefore the complete 3-character prompt after a cold reset is $E0, $00, $3E. MOTOROLA For More Information On This Product, MONITOR RESET NO WARMSTART ? YES PROMPT (BAD SP) Figure 2. Determining Cause of Monitor Reset Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Command Error Codes GENERATE longBreak PROMPT (COLD RESET) 11 ...

Page 12

... Freescale Semiconductor, Inc. AN2548/D Some commands are not allowed while the target MCU is in run mode because they would interfere with proper execution of the application program (see $E2 — Command Not Allowed in Run recommended while the target MCU is in run mode. However, because these ...

Page 13

... The debug tool or programmer running in the host PC can perform additional memory reads to get more detailed information about the error. MOTOROLA For More Information On This Product, $AA — Write_SP Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Command Error Codes for details. 13 ...

Page 14

... Freescale Semiconductor, Inc. AN2548/D Monitor Status Codes The second character of a 3-character prompt is a status code that tells the host debug program the current state of the monitor. $00 — Monitor This code indicates that the user application program is not currently running Active and the monitor is active and waiting for further commands from the host. $01 — ...

Page 15

... EEPROM block to 0x0000 */ /* lock Ram to end at 0x3FFF */ configurations. create a copy of the application’s vectors in a jump table from $F780–$F7FF. Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Software Detail 15 ...

Page 16

... Freescale Semiconductor, Inc. AN2548/D 4. Application code should exclude the $F780–$FF7F memory. For assembly programs — In the CodeWarrior assembler, the following definition may be added to generate an automatic error if this occurs: IF EndOfApplication >= $F780 FAIL "Application code overflows into Monitor area" ENDIF The application just needs to define the EndOfApplication label to reference the end of the application code ...

Page 17

... SpSub routine. The TFR in the next line copies the SP into the IX register so X points to the start of the copy of MOTOROLA For More Information On This Product, WriteD2IX Subroutine Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Software Detail for details. 17 ...

Page 18

... Freescale Semiconductor, Inc. AN2548/D SpSub on the stack. The next line preloads A with a mask corresponding to the CBEIF bit which will be used to complete the FLASH command. At this point if the monitor program is active, the I bit in the CCR is already set to mask interrupts; however, since this routine can also be called as a utility subroutine from a user program, the I bit may or may not be set at the time DoOnStack is called ...

Page 19

... CCR which is initially set to $D0 (SX-IN---). The I bit is set, which disables all maskable interrupts. The user PC is initially loaded with the user reset vector at $F7FE:$F7FF assuming that the lsb of the vector is not $FF. Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Software Detail 19 ...

Page 20

... Freescale Semiconductor, Inc. AN2548/D User-Accessible One of the most common ways to reduce code space is to develop a good set Utility Subroutines of utility subroutines. A good utility subroutine is one that can be used in several different contexts to perform some common task. The following utility subroutines are provided for the user: • ...

Page 21

... You may wish to change the port pins for the switch that forces monitor versus Switch user mode and for the SCI RxD pin. These changes can be made by modifying the equate directives at the beginning of the monitor program. MOTOROLA For More Information On This Product, Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Software Detail 21 ...

Page 22

... Code Listing Companion software for this program is available from the Motorola web site, http://motorola.com/sps: AN2548SW1.zip — Complete Assembly source files AN2548SW2.zip — Full CodeWarrior project 22 For More Information On This Product, Serial Monitor Program for HCS12 MCUs Go to: www ...

Page 23

... Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, Serial Monitor Program for HCS12 MCUs Go to: www.freescale.com AN2548/D Conclusion 23 ...

Page 24

... Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark Office. digital dna is a trademark of Motorola, Inc. All other product or service names are the property of their respective owners. Motorola, Inc Equal Opportunity/Affirmative Action Employer. © Motorola, Inc. 2003 AN2548/D Go to: www.freescale.com ...

Related keywords