Everything
2.9.4 Execute a specified routine [E1] [E20]

You can execute a specified routine immediately before the start or stop of the program execution. Setting an arbitrary routine allows you to control the target system in synchronization with the execution or stop of the program. See "2.10 Stop Programs (Break)" on how to stop a program in execution. This section describes the procedure for specifying a routine to be executed.

You can specify a routine in the [System] [E1] [E20] category on the [Debug Tool Settings] tab in the Property panel.

-

When executing immediately before the program execution
Select [Yes] in the [Execute the specified routine immediately before execution of the user program] property, and enter the start address in the [Routine to run immediately before execution starts] property that is displayed. The specified routine will be executed immediately before the program execution.

-

When executing immediately after the break
Select [Yes] in the [Execute the specified routine immediately after the user program stops] property, and enter the start address in the [Routine to run immediately after execution stops] property that is displayed. The specified routine will be executed immediately after the stop of the program.

 

If [Yes] is selected either for the [Execute the specified routine immediately before execution of the user program] or [Execute the specified routine immediately after the user program stops] property, the [Work RAM start address for executing a specified routine] property is displayed. The amount of memory indicated by the [Work RAM size [bytes] for executing a specified routine] this property beginning with this address is to be used by the debugger firmware as a work RAM area for the facility to execute a specified routine.

When you wish to use the facility to execute a specified routine, select this work RAM area.

Figure 2.89

[System] category

Caution 1.

In the [Routine to run immediately before execution starts] property, [Routine to run immediately after execution stops] property, and [Work RAM start address for executing a specified routine] property, you can also specify function name (when using C language) or label name (when using Assembly language) as property values.

Caution 2.

Use an interrupt stack when using a stack inside the specified routine.

Caution 3.

Describe an RTS (return from subroutine) instruction for terminating the specified routine processing.

Caution 4.

The processing time of one specified routine must not exceed 100ms. If a clock remains halted in the specified routine, it may affect the control over the debug tool.

Caution 5.

The register value for the start of the specified routine is not determined. As such, you need to perform initial setting of the register value in the specified routine.

Caution 6.

Immediately before execution or immediately after stop of the specified routine, execution enters a stopped state under control of the debug tool. The stop period is determined as follows.

-

User program execution starts about 100 cycles (about 1 μs when CPU clock is 100 MHz) after the specified routine is executed before execution of the user program.

-

Execution of the specified routine starts about 100 cycles (about 1 μs when CPU clock is 100 MHz) after the stop of user program execution.
In on-chip ROM disabled extended mode, execution of the specified routine starts about 3 ms with a CPU clock of 100 MHz, or about 8 ms with a CPU clock of 32 kHz, after the stop of user program execution. This also applies when the user program stops for the first time after the hot plug-in connection is established.

Caution 7.

Execution of a specified routine starts in the supervisor mode. Do not switch it to the user mode.

Caution 8.

When executing a specified routine, do not perform memory access/download/break point setting to the program area of the specified routine.

Caution 9.

While the facility to execute a specified routine is in use, 230h (560) bytes of RAM starting from [Work RAM start address for executing a specified routine] is reserved for exclusive use by the emulator.
This area must not be used by the user program or routine.
Also be sure to allocate this area to the internal RAM area.
The value of [Work RAM start address for executing a specified routine] must be a multiple of four.

Caution 10.

Following restrictions will apply to the general registers and flags used in the specified routine.

ISP Register

Once the specified routine is executed, the value should be returned to the one at the start of the execution.

U Flag

Setting the user stack pointer (USP) is prohibited while the specified routine is in execution.

I Flag

Interrupt is prohibited while the specified routine is in execution.

PM Flag

Switching to the user mode is prohibited while the specified routine is in execution.

Caution 11.

While the specified routine is in execution, the trace, break, real-time RAM monitor and timer measurement will be disabled.

Caution 12.

Non-maskable interrupt is always prohibited while the specified routine is in execution.

Caution 13.

When starting a program after executing the specified routine, the state of microcontroller will be as follows

General Register

Remains in the state at which the program stopped or reflects the user setting. The contents of the register following the execution of the specified routine are not reflected.

Memory

Reflects the memory access made after the execution of the specified routine.

Peripheral Functions

The operation of microcontroller peripheral functions after the execution of the specified routine continues.

Caution 14.

If a stack is to be used in the specified routine, the ISP register must be set up in the routine. When the specified routine is started, the value of the ISP register is that of [Work RAM start address for executing a specified routine].

Caution 15.

Once the execution of the specified routine is completed, the value of the ISP register must be returned to the value at the start of the execution.

Caution 16.

While the facility to execute a specified routine is in use, do not input a reset signal through the reset pin or allow the watchdog timer to reset the CPU.

Caution 17.

While the facility to execute a specified routine is in use, do not disable the internal RAM area.

Caution 18.

While the specified routine is running, do not set the U flag to 1 (i.e. setting the user stack pointer, or USP).

Caution 19.

While the specified routine is running, do not use RTFI (return from fast interrupt) instructions.

Caution 20.

Do not set breakpoints or cause break events, trace start events, or trace end events in the specified routine.
If a break event occurs within the routine to run before execution of the user program, for example, the program stops immediately after it has started running. If a trace start event occurs within the routine, no trace data is acquired while the routine is running. Trace acquisition is not resumed until the user program starts running. The emulator will not behave as expected.

Caution 21.

While the facility to execute a specified routine is in use, if the Start function does not shift to the user program, or the Stop function does not stop, an error message "A timeout error has occurred in Start/Stop function processing. The system was reset." is displayed. The emulator is initialized and the user program stops. After the system is reset, trace records are initialized too. You can continue with debugging.