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 |
When executing immediately after the break |
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.
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. |
Describe an RTS (return from subroutine) instruction for terminating the specified routine processing. |
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. |
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. |
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. |
When executing a specified routine, do not perform memory access/download/break point setting to the program area of the specified routine. |
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. |
Following restrictions will apply to the general registers and flags used in the specified routine. |
While the specified routine is in execution, the trace, break, real-time RAM monitor and timer measurement will be disabled. |
When starting a program after executing the specified routine, the state of microcontroller will be as follows |
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]. |
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. |
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. |
While the facility to execute a specified routine is in use, do not disable the internal RAM area. |
While the specified routine is running, do not set the U flag to 1 (i.e. setting the user stack pointer, or USP). |
While the specified routine is running, do not use RTFI (return from fast interrupt) instructions. |
Do not set breakpoints or cause break events, trace start events, or trace end events in the specified routine. |
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. |