Keil Logo Arm Logo

Flash Breakpoints

Flash Breakpoints use IAP (In-Application Programming) to replace breakpoint instructions with CALL instructions into the ISD51 code. Flash breakpoints are supported on all devices that offer IAP and have relatively small Flash block sizes (128 bytes or less). Numerous Flash breakpoints can be enabled simultaneously. They require almost no overhead and allow programs to execute at full speed.

When you set a Flash breakpoint, ISD51 modifies the code memory and inserts a CALL instruction at the breakpoint address. When the breakpoint is reached, ISD51 is invoked (by the CALL). Run-time address checking (which is what software breakpoints do) is not required.

To use Flash breakpoints, you must configure ISD51 for your target MCU. There is a place in the ISD51.H header file where you may configure the Flash block size and the algorithm to program a block.

CBLK_SZ specifies the flash block size in bytes. If it is 0, Flash breakpoints are not enabled. If it is non-zero, a memory buffer (named CBLK) is reserved in IDATA for a single Flash block.

The CWRITE macro defines the flash erase and programming function. On entry, A contains the MSB and R0 contains the LSB of the Flash memory block to reprogram with data from the CBLK buffer. You must write the code that reprograms the Flash block.

Note

  • Example configurations for the Infineon C868, Philips LPC900, and TI MSC1210 include Flash breakpoints.

Known Issues

To perform a Flash breakpoint, ISD51 inserts a CALL instruction in the user program at the breakpoint address. This avoids extra hardware for the breakpoint logic. However, the CALL instruction occupies up to three bytes and may therefore cause side-effects when set before a label (jump target) on one-byte and two-byte CPU instructions. For example:

0100  E4        CLR     A
0101  74 03     MOV     A,#3
   .    .        .
   .    .        .
   .    .        .
0110  80 ED     SJMP    0101
  1. The user program executes to address 0x110. The next single-step will execute the SJMP 0101 instruction.
  2. A breakpoint is set at address 0x100 by writing a CALL instruction into the user program. The user program is modified as follows:
    0100  XX        LCALL           ; A CALL instruction is
    0101  XX XX     ???             ; written at address 0x100.
       .    .        .
       .    .        .
       .    .        .
    0110  80 ED     SJMP    0101
    
  3. When the user program continues execution at address 0x110 the program jumps to address 0x101. But, this memory location was modified when the breakpoint was set at address 0x100. The MOV A,#3 instruction is no longer in program memory and is not the instruction executed. And, the behavior of the user program is unpredictable.

To avoid this problem, in C applications use the disassembly window and check to see if the instruction sequence described above exists. The following C statements may cause such side-effects:

  • Breakpoint near the beginning of a loop. For example:
      while (...) {
        // Breakpoints near the beginning of
        // a loop start may cause problems.
        ...;
      }
    
  • Breakpoint near the end of a function. For example:
    void func1(void) {
      ...
    }
        // Breakpoints near the end of a function
        // may modify the beginning of the next function.
    
    void func2(void) {
      ...
    }
    

Note

  • The linker does not locate functions in ascending sequence.

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.