Information in this file, the accompany manuals, and software is
Copyright © Keil Software, Inc and Keil Elektronik GmbH.
All rights reserved.
Version 1.0: initial release
Version 2.0: adds flash breakpoints, user I/O via serial debugging interface and address range for the memory verify function.
ISD51 (In-System Debugger) provides a new debug monitor technology for 8051 user programs. ISD51 a configurable library that you link to your user programs to provide support for program testing via the 8051 on-chip UART.
The software and hardware requirements of ISD51 are minimal. It can run from external or on-chip CODE space and requires no special hardware components like von Neumann-wired memory.
ISD51 works on both very small 8051 devices like the Philips LPC series and on complete systems that have access to the full CODE and XDATA address space.
The current version of ISD51 has the following restrictions:
ISD51 adds a serial interrupt function (ISD51 interrupt) for the 8051 UART to your user program. When ISD51 connects to the µVision2 Debugger, the 8051 enters the ISD51 interrupt function. As long as the program execution is stopped, the 8051 program runs only the ISD51 interrupt function. When the µVision2 Debugger issues a Go command, the 8051 leaves the ISD51 interrupt function and executes the user program.
When you set flash breakpoints or hardware breakpoints, the 8051 executes the user program in full speed. Flash breakpoints can be easily configured for many current 8051 device variants that support In-Application Flash programming with sector sizes up to 128 Bytes.
If the device does not support flash breakpoints you may use software breakpoints. In this case, the 8051 enters the ISD51 interrupt function after each 8051 CPU instruction. The ISD51 interrupt checks if the 8051 program reached a breakpoint address and, if so, begins communication with the µVision2 Debugger. Therefore, the 8051 program executes considerably (about 100x) slower when software breakpoints are used.
The µVision2 Debugger sends a 0xA5 character to the ISD51 interrupt function to halt the user program and start communication with the debugger. For this reason, 8051 program must be started when the µVision2 Debugger is invoked.
The following steps are required to add ISD51 features to your application.
Program that demonstrate how to add ISD51 capability are provided in the \C51\ISD51\EXAMPLES folder.
ISD51 provides several functions your application may use. These functions and macros are prototyped in ISD51.H.
ISD51 is initialized with one of the following function calls:
ISD51 breakpoint handling can be influenced with:
ISD51 specific serial user input/output functions work via the UART interface that is used for debugging. The functions are enabled with the defines ISD_PUTCHAR and ISD_GETKEY. When enabled, functions like printf and getchar communicate via the Serial Window of the µVision2 debugger. Since the UART is already configured for ISD51 communication, no additional serial initialization is required. ISD51 defines in addition to the standard putchar and _getkey functions:
ISD51 supports flash breakpoints for devices with IAP (In-Application Programming) support and flash block sizes up to 128 Bytes. ISD51 modifies for flash breakpoints the code memory and inserts CALL instructions. The IAP functions are configured in the ISD51.H header file that you have added to your project. The define CBLK_SZ specifies the flash block size and the macro CWRITE defines a flash erase and programming function.
To perform a flash breakpoint, ISD51 inserts a CALL instruction in the user program. This avoids extra hardware for the breakpoint logic. However, the CALL instruction occupies up to three bytes and therefore breakpoints may have side effects when set before a label (jump target) on one or two byte CPU instructions. The following example demonstrates this problem.
0100 E4 CLR A 0101 74 03 MOV A,#3 : : : : : : 0110 80 ED SJMP 0101
First, the user program is executed until address 0x110 with a µVision2 debugger command like G, 0x110.
Then, a breakpoint is set at address 0x100. The breakpoint is realized by writing a CALL instruction into the user program which means that the user program is modified by the breakpoint.
0100 XX LCALL ; An CALL instruction is 0101 XX XX ??? ; written at address 0x100. : : : : : : 0110 80 ED SJMP 0101
When the user program continues execution at address 0x110 the program jumps to address 0x101. But this memory location is modified due to the breakpoint at address 0x100. Therefore, the MOV A,#3 instruction will be not executed and the behavior of the user program is unpredictable.
In C applications, use the disassembly window and check if the instruction sequence described above exists. The following C statements may cause such side effects:
while (...) { // a breakpoint near a loop start may cause problems.
...;
}
void func1(void) {
...
} // a breakpoint here, may modify the beginning of the next function.
void func2(void) {
...
}
Note: The linker does not locate functions in ascending sequence.
The TI MSC1210 supports hardware breakpoint registers that can be enabled in the ISD51.H header file with the define TI_MSC1210_BREAKS. When used, this hardware breakpoints may generate the following side effects:
void func(void) {
while(...) {
...;
}
...; // a breakpoint here may stop, even when the loop is not finished
}
void func1(void) {
...
}
void func2(void) { // a breakpoint here may stop, when the CPU is at the end of func1
...
}
Note: The linker does not locate functions in ascending sequence. Therefore the function order in the C source module will not match the order in the memory. Review the function segment information in the linker map (*.M51) file or use the disassembly window to determine the function order in memory.
void func1(void) {
...
func2();
... // a breakpoint here may stop the CPU at the beginning of func2
}
Note: This affects even the Step Over command which inserts also a breakpoint
after CALL instructions.
The CPU may stop at the beginning of the called function.
Once you have added ISD51 to your program, you may configure the µVision2 Debugger for communication with the 8051 target system.
COM Port Settings
- Port: PC COM port used to connect to the 8051 target hardware.
- Baudrate: Communication baud rate with the 8051 target hardware.
- RTS Logical: Level on the RTS line of the COM Port (see below).
- DTS Logical: Level on the DTS line of the COM Port (see below).
RTS and DTS settings
- Always high (active): Signal is always active during µVision2 Debugger communication.
- Always low (in-active): Signal is always inactive during µVision2 Debugger communication.
- Reset high 500ms (active) on start: on Reset Command of µVision2 Debugger the Signal is active for 500 mSec.
- Reset low 500ms (in-active) on start: on Reset Command of µVision2 Debugger the Signal is inactive for 500 mSec.
- Reset pulse: 500ms high, 10ms low: on Reset Command of µVision2 Debugger the Signal is active for 500 mSec, then in-active for 10 mSec, and then active again.
- Reset pulse: 500ms low, 10ms high: on Reset Command of µVision2 Debugger the Signal is in-active for 500 mSec, then active for 10 mSec, and then in-active again.
Cache Options
The ISD51 driver implements data caches to speed-up screen updates.
- Disable the cache options to view actual (un-cached) values of DATA (and SFR), IDATA, or XDATA space when you halt program execution. This way you can be certain you are viewing the current values of I/O ports, timers, or memory-mapped peripherals.
- Enable the cache options to obtain maximum performance.
Code Breakpoint Options
This option selects whether or not ISD51 uses software breakpoints, hardware breakpoints, or a combination of both.
- If your target 8051 device does not support hardware breakpoints, you must select software breakpoints only.
- If your target 8051 device supports hardware breakpoints, you must use software breakpoints when no hardware breakpoints are available.
Miscellaneous Options
The Verify if Application in ROM is identical to current Project option selects whether or not the µVision2 ISD51 Debugger Driver compares the program code in the 8051 target with the program code of the current project when initializing ISD51 communications. You may disable this option to speed-up the connection time of the debugger with the target system.
If your application requires specific configuration areas, you may configure the verify address range with the defines CMP_START and CMP_END in the ISD51.H header file.
ISD51 Identification
This box displays the version number and other status information when the µVision2 Debugger connects to the ISD51 running on the 8051 target system. You may check this information when you open the ISD51 Driver Settings dialog during debugging.
Once the µVision2 Debugger is configured, you may start debugging with Debug - Start/Stop Debug Session. The µVision2 Debugger connects to the 8051 target system via the ISD51 software.
ISD51 supports most µVision2 debugger features. For instance, you may single-step through code, set breakpoints, and run your application. Variables may be viewed using the standard debugger features.
There are several restrictions you must consider when using ISD51 and the µVision2 Debugger.
If the µVision2 Debugger does not connect to the ISD51 hardware you should first verify that the target system's serial interface is correctly configured. You may check this by using the µVision2 Simulation as follows:
If everything is correctly configured and you are still unable to connect to the IDS51 hardware, your 8051 program may call the following function after initializing the serial interface.
/*
* Test Function: verify serial communication with HyperTerminal
*/
void TestSerial (void) {
char c = 'A';
TI = 1;
while (1) {
if (RI) {
c = SBUF;
RI = 0;
}
while (!TI);
TI = 0;
SBUF = c;
}
}
This function outputs the character A via the serial interface. If you transmit a character via the serial interface to the user program, that character will be sent instead. You may check this using a terminal program like HyperTerminal to see if the 8051 correctly outputs the A character and if the output character changes when you send a different character.
At Keil Software, we are dedicated to providing you with the best development tools and technical support. That's why we offer numerous ways you can get the technical support you need to complete your embedded projects.
Many of the features of our Technical Support Knowledgebase and Web Site are the results of your suggestions. If you have any ideas that will improve them, please give us your feedback!
Copyright © Keil Software, Inc. and Keil Elektronik GmbH.
All rights reserved.
Visit our web site at www.keil.com.