Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
46
Добавлен:
14.04.2015
Размер:
2.08 Mб
Скачать

Getting Started and Creating Applications

201

 

 

Serial Transmission Line

Monitor-51 requires the following signals from the RS232 or V.24 line:

TRANSMIT DATA, RECEIVE DATA, and SIGNAL GROUND. In many cases, additional connections are necessary in the serial connectors to enable transmit and receive data.

PIN connections of various computer systems

25 Pin Connector

 

 

9 Pin Connector

 

 

 

 

 

 

 

 

11

 

 

 

 

 

 

 

 

 

Signal Name

Pin

Description

 

 

Signal Name

Pin

Description

 

RxD

3

Receive data

 

 

RxD

2

Receive data

 

TxD

2

Transmit data

 

 

TxD

3

Transmit data

 

 

 

Gnd

7

Signal ground

 

 

Gnd

5

Signal ground

 

 

 

 

 

 

 

 

 

 

 

 

In addition to the above, you may be required to connect pin 7 to pin 8 and pin 1 to pin 4 and pin 6.

µVision2 Monitor Driver

µVision2 interfaces to target systems when you select Use: Keil Monitor-51 Driver in the dialog Options – Debug.

Click on Settings to open the dialog Monitor Driver Settings that allows you to configure various parameters such as COM port and baudrate. Refer to “Set Debug Options” on page 102 for more information about the Debug dialog.

202 Chapter 11. Using Monitor-51

The following table describes the Monitor Driver Settings page:

 

 

Dialog Item

Description

 

 

 

Comm Port Settings

Select the PC COM port and the baudrate you want to use. If you have

 

 

 

 

problems with your target hardware, try the Baudrate 9600.

 

 

 

 

Sometimes not standard baudrates allow to use a different crystal frequency

 

 

 

 

on a target board without having to reinstall Monitor-51. Example: A target

 

 

 

 

board running at 12 MHz and 9600 bps can be modified to a 16MHz and

 

 

 

 

12800 bps by just exchanging the crystal.

 

 

 

Stop Program

When Serial interrupt is enabled, you can terminate a running application

 

 

 

Execution with

program with the Stop toolbar button or the ESC key in the Command page.

 

 

 

 

To support this, the serial interface is not longer available for the user

 

 

 

 

program. In addition, it is not allowed to reset the global Interrupt Enable

 

 

 

 

 

11

 

 

(SFR Bit EA in IE.7) in your application.

 

 

Cache Options

To speed up the screen update, the Monitor driver implements several data

 

 

 

caches. If you want to view the actual value of port pins, timers or memory

 

 

 

mapped external peripherals you can switch off the cache for this memory

 

 

 

 

area. To get the maximum performance you should enable all caches.

 

 

 

 

 

µVision2 Restrictions when using Monitor-51

The memory mapping of a CPU board with Monitor-51 is selected with hardware components. It is not possible to use Debug – Memory Map to change the memory mapping of the target system.

The Performance Analyzer, Call Stack, Code Coverage features, and the Step Out command are not available with Monitor-51. Also the option View – Periodic Window Update cannot be used with Monitor-51.

Breakpoint Options are handled directly by Monitor-51. However, when access or conditional breakpoints are set, the application is executed in single steps and not in real time. Single step execution is at least 1000 times slower.

Getting Started and Creating Applications

203

 

 

Breakpoint Side Effects

When debugging programs it is sometimes necessary to stop the running of programs in order to check the system and eventually to correct any errors. To perform a breakpoint Monitor-51 writes a ACALL instruction in the user program. The advantage of this method is, that no additional hardware is required for the breakpoint logic. But with this method breakpoints can only be set in RAM memory. A second disadvantage is that a ACALL instruction occupies two bytes. Therefore, it can be dangerous, to set a breakpoint on a one-byte instruction, if a label (jump target) is after this instruction. The following example demonstrates this problem.

Test Program

 

 

11

 

 

 

 

 

8000

E4

 

CLR

A

8001

04

 

INC

A

 

.

.

 

.

 

 

.

.

 

.

 

 

.

.

 

.

 

 

8010

80

ED

SJMP

8001

 

First, the user program is executed until address 8010 with the following command.

>G 8000, 8010.

Afterwards, a breakpoint is set at address 8000. The breakpoint is realized by writing a ACALL instruction into the user program; this means that the user program is modified by the breakpoint.

Modified Test Program

8000

11

 

CLR

A

; An ACALL instruction is

8002

XX

 

INC

A

; written at address 8000.

.

.

 

.

 

 

.

.

 

.

 

; Address 8001 is

.

.

 

.

 

; occupied by the target of

8010

80

ED

SJMP

8001

; the ACALL instruction.

If the interrupted program is continued at address 8010, the execution is not stopped at 8000. The reason is, that the user program jumps to address 8001 after the execution of the SJMP instruction. But at this address the second byte of the ACALL instruction resides in memory—not the INC instruction. Therefore the program execution at this point is unpredictable.

204

Chapter 11. Using Monitor-51

 

 

The user has to check that the ACALL instruction of a breakpoint overwrites no important OP codes. If needed, the user program should be executed by the Trace command. The Trace mode executes all instructions without conflicts.

Tool Configuration when Using Monitor51

When you use Monitor-51, the complete target application is stored in von Neumann mapped RAM. This means that the code memory and xdata memory are accessing the same physical memory space. This is required, since the 8051

11 hardware is not able to write into code space and the Monitor changes the program code to set breakpoints in your application.

Therefore the Eprom and RAM areas that are entered in the dialog Options – Target – Off-chip Memory must be non-overlapping physical memory areas. These ranges are supplied to the Linker if you have enabled the option Use Memory Layout from Target Dialog in the L51 Locate dialog page. Therefore you should also check that this option is set.

For debugging with Monitor-51 the code and xdata space of the user application must be non-overlapping memory areas. Otherwise the user application overwrites the program code when xdata variables are accessed.

Getting Started and Creating Applications

205

 

 

Using Stop Program Execution with Serial

Interrupt

When you have enabled the option Stop Program Execution with Serial Interrupt, the Monitor-51 uses the serial interrupt of the UART. If you are using the standard 8051 UART, three bytes at the interrupt vector location C:0x0023 are modified by Monitor-51. You must ensure that the user program does not use these code locations. This can be done with the following C statements:

char code reserve [3] _at_ 0x23; /* for Monitor-51 serial interrupt */

11

When the Monitor-51 is Installed at Code Address 0

If you want to test a C program with Monitor-51 and if the Monitor-51 is installed at code address 0, consider the following rules (the specification refers to a target system where the available code memory for user programs starts at address 0x8000):

All C modules which contain interrupt functions must be translated with the control directive INTVECTOR (0x8000). This option can be set under µVision2 in the dialog Project Options - C51 - Interrrupt vectors at address.

Copy the file \KEIL\C51\LIB\STARTUP.A51 into your project folder and add this file to your µVision2 project. In this copy of the STARTUP.A51 the statement CSEG AT 0 must be replaced with CSEG AT 8000H.

Соседние файлы в папке HLP