You are on page 1of 5

Stopping A Running HC908 Target

The HC08 architecture does not have any built in functionality to stop a running target.
Therefore, in previous scenarios, once a user had started a target running, there were only
three way to regain control of the MCU:

(1) execute an SWI instruction pre-placed into code,


(2) encounter a breakpoint,
(3) or reset the device.

P&E has introduced a feature that will allow method (1) from above to be expanded to
allow the user to stop a running target by issuing a stop command, rather than pre-
planning the point where an SWI will occur. Please note that the following features are
only valid for users who are using any of the Multilink or Cyclone products for the
HC908 family:

Extended Break Feature

When a stop command is issued through the debugger, a >10ms low pulse will be sent
out on the COM line. This allow the user to poll the COM line in the main loop and issue
an SWI when the line goes low. This feature is always enabled, and is non intrusive to
user’s code (if the user does not use this feature, debugging will not be affected in any
way).

Pulse IRQ on Stop Feature

The user can also enable an IRQ event to be triggered when a stop command is issued.
This will give the user the added option of creating an ISR that will execute an SWI
instruction when the IRQ event is detected by the MCU, or polling the IRQ flag and
triggering the SWI manually (this will allow for applications in which interrupts are not
used to use this feature). Note that user’s who are using the IRQ line for other functions
should not enable this feature.

To enable the IRQ Toggle on Stop feature, enter the Advanced Menu from the
“Attempting to Contact Target Dialog” (please see figure below):
After entering this menu, please check the “Pulse IRQ on Stop” checkbox. (see image
below)

Once this feature is enabled, the IRQ line will be pulsed low for 500 uS every time a stop
command is issued from the debugger. Before this occurs, a 10mS break signal (low
signal) will be sent over the communication line. The break will be transmitted regardless
of the state of the “Pulse IRQ on Stop” checkbox.
Code Examples for Implementation

The following are brief code snippets to implement each of these various methods of
stopping a running target.

Polling COM line

This method doesn’t require setting any options—a break is always transmitted when a
stop command is issues. Please note that the below example assumes a COM line of
PTA0:

Main_Loop: ; user’s main loop


brset 0,PORTA,continue ; If PORTA0 is not low, then continue with code
swi ; stop execution if the COM has gone low
Continue:
… ; other main loop code is placed here

Polling the IRQ Line

In order for this method to function properly, the “Pulse IRQ on Stop” checkbox must be
checked:

Main_Loop: ; user’s main loop


brclr 3,IRQSCR,continue ; If IRQ flag is clear low, then continue with code
bset 2,IRQSCR ; Acknowledge the IRQ
swi ; stop execution if the IRQ flag is set
Continue:
… ; other main loop code is placed here

IRQ Interrupt

In order for this method to function properly, the “Pulse IRQ on Stop” checkbox must be
checked:

Interrupt_Vector equ $FFFA ; IRQ Interrupt Vector Location

Main_Loop: ; User’s main loop





IRQ_ISR: ; This is the IRQ interrupt service routine
swi ; Stops code execution when interrupt occurs
rti ; Returns from interrupt

org Interrupt_Vector
dw IRQ_ISR ; points the interrupt vector for the IRQ to the
; appropriate interrupt service routine

You might also like