Debugging on HC08 Using MON8

Every member of the HC08 microcontroller family is equipped with a basic support for in-system programming and debugging (MON8, for details see datasheet of a HC08 processor). The microcontroller can work in two modes - normal mode and monitor mode.

In the monitor mode the microcontroller can accept couple of commands over the single wire interface. The commands allow to read/write the memory and run a code. In combination with Break module a simple debugging system can be built (e.g. ICS boards, P&E Multilink or various custom designs).

There are few issues that results from the characteristics of the the MON8 system:

  • To achieve a standard communication speed (19200, 9600, 4800 bauds) a specific oscillator frequency must be used (usually 9.83 or 4.915MHz). Suitable source of processor clock is usually part of the debugging system. The user must set the same clock frequency in the CPU bean of his project to ensure that the timing of components will be correct. Care must be taken when using PLL and SpeedModes. Change of the operating frequency of the target processor can result in lost of communication with the target system.
  • Some processor models allows to by-pass internal divider-by-2, which effectively doubles the bus clock of the processor. The bypass is selected by logic state of selected input pin (e.g. PTC3) during processor reset. The user must set appropriate property in the CPU bean to reflect actual state of the pin.
  • One I/O pin (e.g. PTA0) is used for communication with the host computer, therefore it can't be used as a general I/O pin.
  • In some configuration of the debugging system the IRQ pin can be also used to control the target board, therefore it can't be used in user application.

 

Capturing unused interrupts

The debugging system based on MON8 allows only one breakpoint placed in the flash memory. However, executing an SWI instruction while running is functionally equivalent to hitting a breakpoint, except that execution stops at the instruction following the SWI. The user can use this feature to actively capture unused interrupts. There are two options of capturing such interrupts :

  • If the property named 'Unhandled interrupts' located in Build Options tab is set to Own handler for every, there is an interrupt routine generated for each unhandled interrupt generated into CPU.c module. The SWI instruction can be placed in the generated routine of the interrupt that need to be caught.
  • The user can also use the InterruptVector bean. In the properties of the bean select which interrupt will be monitored and set the name of the ISR function - e.g. Trap. One function can be used to capture more interrupts if property Allow duplicate ISR names is set to yes. The Trap function will contain only the SWI instruction:
    __interrupt void Trap(void)
      {
        asm(SWI);
      }

 

 

[top of page]