About

Application Note 175:
Use ISD51 on TI MSC121x

Revision 1 - July 15, 2003

This Application Note tells you how to configure and use the ISD51 In-System Debugger on an TI MSC1210 or similar devices. The application note comes with several example programs that are explained in the following text.

Information in this file, the accompany manuals, and software is Copyright © Keil Software, Inc and Keil Elektronik GmbH.
All rights reserved.

Revision History:

  1. July 15, 2003: Initial revision


Flash Monitor - Overview

Overview

Keil Software offers two innovative debugging solutions for single-chip 8051 microcontroller variants. Both debuggers run from external or on-chip CODE space and require no special hardware components like von Neumann-wired memory and are briefly described below:

  • ISD51 In-System Debugger is a configurable module that you link to your user programs and uses to the 8051 on-chip UART for program testing. ISD51 works on any devices and has minimal software and hardware requirements. ISD51 is optimal for devices with limited memory resources like:
    • Philips LPC series
    • Philips 80C51Rxx or Philips 80C66x
    • TI MSC121x series
    • Analog Devices ADuC8xx series
    • or any 8051 device without XDATA memory.
  • FlashMon Target Monitor is a variant of the popular Keil Monitor-51 that includes a Flash programming interface. FlashMon is very flexible and can be configured for 8051 device variants with on-chip Flash ROM and In-Application Programming (IAP) capabilities.

Comparison between ISD51 and FlashMon

Specification | FlashMon Version 4 | ISD51 Version 2
Compatible Devices | 8051 Derivatives with IAP capability | All 8051 Derivatives
CODE space used | 4 - 5 KBytes | 0.5 - 0.65 KBytes
IDATA RAM used | 6 Bytes on User Stack | 2 bytes IDATA RAM for each software breakpoint
XDATA RAM used | 256 Bytes | - not required -
Required C51 Package | PK51 Professional Developers Kit | PK51 Professional Developers Kit
Debug Interface | RS232 on- or off-chip | on-chip 8051 compatible UART


Example Projects

The following table lists the example projects that are available for the TI MSC121x and pre-configured for using Keil ISD51. The example projects are created with the Keil PK51 Professional Developers Kit.

Project | Description
...\C51\ISD51\Examples\TI_MSC121x | Generic ISD51_Demo project for the MSC121x that shows the features of the ISD51 In-System Debugger
...\C51\EXAMPLES\TI MSC121x\AD4Input | Prints the input voltage of the four input pairs AIN0-AIN1, AIN2-AIN3, AIN4-IN5, AIN6-AIN7 of the MSC121x
...\C51\EXAMPLES\TI MSC121x\AD_Interrupt | Interrupt driven example that prints the voltage of the input pair AIN0-AIN1
...\C51\EXAMPLES\TI MSC121x\AD8Input | Prints the input voltage of all eight analog inputs

The following Application Note uses the AD_Interrupt example to explain the usage of the ISD51 In-System Debugger. If you do not have a target hardware, you can run the example projects in the µVision2 Simulator.


Install the TI Flash Download Utility

The example projects can be programmed into the on-chip Flash ROM of the TI MSC121x parts. Therefore you should install the TI Downloader program.

The Utility is available from the TI website or is located on the TI CD-ROM in the folder Download. Start the Setup.exe to install it on your PC.


Hello Example

AD_Interrupt Example

The AD_Interrupt sample program is located in ...\C51\EXAMPLES\TI MSC121x\AD_Interrupt.

The AD_Interrupt program reads the input pair AIN0-AIN1 of the MSC121x using an interrupt service routine. The analog value is printed along with other A/D relevant information via the serial interface.This example uses floating point arithmetic to convert the A/D result.

Open the AD_Interrupt Project

In µVision2 applications are maintained in project files. To load this example project, select Open Project from the Project menu and open AD_Interrupt.UV2 in the folder ...\C51\EXAMPLES\TI MSC121x\AD_Interrupt.

Select Target

The example is available in three targets:

  • ISD51 - DAQ - 1.84MHz
    Generates the program for the TI MSC1210-DAQ-EVM board that uses 1.8432MHz XTAL. It can be debugged using the ISD51 In-System Debugger with 9600bps communication baudrate.
  • ISD51 - EVM - 11.0592MHz
    Generates the program for the TI MSC1210 EVM board that uses 11.0592MHz XTAL. It can be debugged using the ISD51 In-System Debugger with 9600bps communication baudrate.
  • Simulator
    Generates the program for running without ISD51 (at 11.0592MHz) or with testing with the µVision2 Simulator.

You need to select the target that you want to build from drop-down menu in the Build toolbar.

Compile and Link AD_Interrupt

When you are ready to compile and link your project, use the Build Target command from the Project menu or the Build toolbar. µVision2 begins to translate and link the source files and creates an absolute object module that you can load into the µVision2 debugger for testing. The status of the build process is listed in the Build page of the Output Window.

Note

  • You should encounter no errors when you use µVision2 with the provided sample projects.

Flash Download to the TI MSC1210 Board

Once the AD_Interrupt program is generated, you can download the application into on-chip Flash ROM of the MSC1210x device on the MSC1210-EVM or MSC1210-DAQ-EVM Evaluation Board. You need to setup the boards as described below:

  • Connect the COM Port to the PC COM1 interface using a standard 9-pin connector cable.
  • For the MSC1210-EVM you need a power supply (5V .. 9V=, 100mA). The MSC1210-DAQ-EVM board is powered from the PC COM interface.

When you are ready to download the AD_Interrupt application to the MSC1210 board, use the µVision2 menu command Flash - Download. This starts the TI Downloader which programs the application to the on-chip Flash ROM of the MSC1210 device. The screen should look like below.

In case of errors check the power supply or COM interface of the MSC1210 board.

Run AD_Interrupt on MSC1210 board

Once the program is downloaded to the MSC1210 board, you can start the µVision2 Debugger and use the µVision2 Debug commands. You can find detailed information in the µVision2 Getting Started User's Guide that is available in the Project window - Books tab.

Start the Debug Mode in µVision2 and wait until the connection to the MSC1210 is established.

Open the C Source

You may close the Disassembly Window and use the Next Statement command to open the C source Window

Then you can start the program with Run and watch the output in the Serial Window 1.

The following table gives you a brief introduction into some debug commands.

Debug Command | Description
Start/Stop Debug Session | Start or stop µVision2 Debug Mode.
Step Into Stop Run | Using debugger commands you may single step through code, set breakpoints, and run the application.
Watch Window Reset CPU | Variables can be review in watch windows. And you may reset the device to re-run the application.
Disassembly Window | Open or Close the disassembly window.
Next Statement | The yellow arrow marks the current assembler or C statement.
Serial Window | The Serial Window of the µVision2 Simulator acts as a terminal.

View Serial Output

The Serial Window shows the output of the AD_Interrupt application. You may connect a battery to the AIN0-AIN1 analog inputs of the MSC1210 device.


Serial Interface

Configure ISD51 Applications

The following steps are required to integrate ISD51 features into your TI MSC121x application and debug using the µVision2 Debugger.

  1. Include ISD51 files in your project. For the TI MSC121x you should use the configured version.
  2. Add initialization code to your application.
  3. Configure µVision2 IDE and Debugger to use ISD51.
  4. Build and Download the Application into on-chip Flash ROM of the TI MSC121x device.
  5. Start Debugging with the µVision2 Debugger.

Include ISD51

For the TI MSC121x you can find a pre-configured ISD51 in the folder ...\C51\ISD51\Examples\TI_MSC121x. You should copy the files ISD51.A51, HWCfr.A51, and ISD51.H from this folder into your project folder and perform the following steps.

  1. Add the copy of ISD51.A51 and HWCfr.A51 to your µVision2 Project.
  2. Add the copy of ISD51.H to the C module that contains the main C function (using #include "ISD51.H").

Sharing the ISD51 Serial Debug Interface

The pre-configured ISD51 version for the TI MSC121x enables serial port sharing. All serial I/O from your program is sent to and read from the Serial Window in the µVision2 Debugger.

The serial port sharing is configured via #defines in ISD51.H. ISD_PUTCHAR and ISD_GETKEY enables the serial I/O routines putchar and _getkey. Once enabled, functions like printf and getchar communicate via the Serial Window. Since the UART is already configured for ISD51 communication, no additional initialization is required. In addition to the standard putchar ad _getkey functions, ISD51 also offers an _iskey function you may use to test for an available character to receive.

Add Initialization Code

The ISD51 requires initialization code for the on-chip UART and the flash programming. You should add the following code to the module that contains your C main function. You may copy this code from the file ...\C51\ISD51\Examples\TI_MSC121x\Test.c or one of the examples provided in the folder ...\C51\Examples\TI_MSC121x.

#include "ISD51.h"

#ifndef XTAL                        // if no XTAL defined use:
  #define XTAL  11059200            // XTAL frequency 11.0592 MHz
#endif

// defines for UART BAUDRATE
#define BAUDRATE          9600      // 9600bps communication baudrate
#define T2RELOAD   (65536-(XTAL/32/BAUDRATE))

  :
  :
  :

void main (void)  {
  :

// Setup Serial Interface
  T2CON   = 0x34;                     // Use Timer 2 as baudrate generator  */
  RCAP2H  = (T2RELOAD >> 8);          // baudrate reload factor
  RCAP2L  = T2RELOAD;

  SCON0   = 0x50;                     // enable serial uart & receiver
  PCON   |= 0x80;                     // double baudrate for UART0
  P3DDRL &= 0xF0;                     // set port pins of UART to input/strong drive output
  P3DDRL |= 0x07;                     // set port pins of UART to input/strong drive output

// The following settings are important for ISD51 (enable flash programming, disable watchdog)
  USEC   = ((XTAL+500000)/1000000)-1; // USEC timer factor
  ONEMS  = (XTAL/1000)-1;             // (MSECH+MSCL) MS Timer counting at 1.0ms

  HMSEC  = 100-1;                     // Hundred MS Timer to 100.0ms
  SECINT = (10-1) | 0x80;             // SECINT= 10 * HMS Timer Rate = 1 sec
                                      // '0x80' will set the MSB for write immediate
  MSINT  = (10-1) | 0x80;             // MSINT = 10ms for Tone period time base

  FTCON  = 0xA5;                      // setup flash programming times

  PDCON  = 0x14;                      // ON -> ADC-Vref, SPI Systimers. OFF -> PWM, Watchdog
  EA     = 1;                         // Enable global interrupt flag

  ISDwait();                          // wait until ISD51 connects

ISD51 has several startup options which are described below. Instead of ISDwait you may use ISDinit or ISDcheck. Take a look to the file ...\C51\ISD51\Examples\TI_MSC121x\Test.c for configuration examples.

  • ISDinit: Initializes ISD51 and starts user program. When the µVision2 Debugger connects, program execution halts.
  • ISDwait: Initializes ISD51 and waits until the µVision2 Debugger connects.
  • ISDcheck: Checks to see if the µVision2 Debugger has connected with the 8051. If so, the ISD51 interrupt is initialized. ISDcheck must be called periodically. You can do this in the main loop of your embedded application.

Configure µVision2

When you create a µVision2 project you need to select a CPU from the Device Database™. You can change the selected device under the Device tab of the Options for Target dialog.

  1. For correct ISD51 configuration, you need to specify the correct XTAL frequency of your target system in several µVision2 configuration dialogs as shown below.

    The XTAL speed in Project -> Options for Target -> Target dialog is used for the µVision2 Debugger/Simulator for correct timing calculations in the peripheral dialogs.

    The XTAL value under Project -> Options for Target -> C51 -> Define is used in the C code of your main module to configure the serial baudrate and the timing for flash programming.

    The TI Download Utility that is automatically configured from the Device Database requires adjustment of the /X parameter which specifies the clock in rounded MHz. For example you should insert /X11 for 11.0592 MHz or /X2 for 1.8432 MHz clock speed.

  2. The TI Download Utility requires an Intel HEX file which is enabled under Project -> Options for Target -> Output.

  3. You need to configure the µVision2 Debugger for ISD51.

    In the dialog Project -> Options for Target -> Debug select Keil ISD51 In-System Debugger .

    Click on Settings to open the ISD51 Driver Settings dialog and enter the parameters that match the Monitor configuration. The TI MSC121x Evaluation Boards use a reset logic that is connected to the RTS and DTR pins. Therefore you should configure the RTS and DTR lines as shown in the figure below:

Build and Download

The µVison2 menu command Project -> Build Target generates the application code µVision2 project.

The TI Download utility can be started with the µVison2 menu command Flash -> Download.

This starts the TI Downloader that programs the application to on-chip Flash ROM of the TI MSC121x device. In case of errors check the power supply or COM interface of the MSC121x hardware.

Start Debugging

Now use Debug -> Start/Stop Debug Session to start the µVision2 Debugger. This will connect to your target system. After your application is loaded to the target system you have full access to 1the µVision2 Debug commands.

In case of communication problems refer to the book ISD51 In-System Debugger. In the section Program Integration - Troubleshooting you can find hints about potential problems. Most like the communication baudrate does not match, so you should check XTAL and baudrate settings first.

The µVision2 Debugger commands are explained in the book µVision2 Getting Started User's Guide. Refer to the section Testing Programs.


Detailed Documentation

You can find detailed information about the µVison2 Debugger/Simulator in the µVision2 Getting Started User's Guide. The book ISD51 In-System Debugger describes the features of the ISD51.