Table of Contents        Previous topic       Next topic       

The Preconfigured Projects->Philips P89C51RX2 Debug Monitor->The Project

The P89C51RX2 chips default to clock doubled operation.  The default 19200 baud rate is therefore maintained by not setting the SMOD bit.  (See InitiSerialPort() in functions.c.)

As with the other debug monitor projects, InitSerialPort() must be modified if your oscillator frequency differs from 11.059MHz.  In addition however, the Philips flash programming routines need to know the oscillator frequency.  You must therefore change the value assigned to the assembler identifier osc_freq, which by default is equated to the value 11 (for 11MHz) near the top of registers.c.

The debug monitor will be compiled to reside in the address range 0000-1FFF hex.  This is the first block of flash memory and so this address range cannot be reduced even though the debug monitor is considerably smaller than this.

The debug monitor expects your code to start at 2000 hex,  Your program's min. code address should therefore be set to 2000 hex.  It's min. xdata address should be set to 3E hex.  If you are using interrupts, then the interrupt vector offset in the compiler options should be set to 2000 hex.

Since the flash memory is only block reprogrammable, breakpoints cannot be set and cleared automatically by the debugger.   Therefore the Step to Cursor command will not function and breakpoints must be set by adding instructions to your source code.

You can set PC breakpoints in your code by explicitly including a long call to the debug monitors BreakPoint() function.  The address of this can be obtained from the debug monitors map file (the address of _BreakPoint).  For the version tested at the time of writing, it resides at address 0948 hex. and so the instruction lcall 0948h will halt execution of your program. Here's an i, j, k, l;main(){   i = j = k = l = 1;   while (1)  {     _asm(" lcall 0948h"); // breakpoint     j++;     _asm(" lcall 0948h"); // breakpoint     k++;  }}
You cannot single step through _asm(" lcall 0948h").  If you single step to it, click on Go.  Execution will then stop at the next instruction.
If you want the breakpoints to be included in the Breakpoint tree, so that you can make them dependent upon each other or set simultaneous source level data breakpoints, then use the Set Breakpoint at Cursor command to set a breakpoint immediately after each lcall instruction. So in the above example you would set a breakpoint at the j++; line and another at the k++; line.

To set a data breakpoint in k for example, right mouse click on k and select 'Set Breakpoint on k'. Click on for example 'Equals' as the breakpoint type, enter a value for k to be equal to and click OK. Then in the breakpoint tree you must drag the data breakpoint onto a PC breakpoint and it will automatically become 'simultaneous with parent'. (You cannot have Read or Write Access data breakpoint with the debug monitor.)

Don't forget that if you modify and recompile debug monitor, the address ofthe Breakpoint function may change.