The ILLEGAL INSTRUCTION error indicates that a break has occurred at an unintended location due to user program runaway.
Major reasons for user program runaway are:
When the user program uses an area larger than the actual MCU’s ROM/ROM:
*Usage notes corresponding to M16C/65 Group (program ROM1 is larger than 512K bytes)
When executing a program assigned to addresses 40000h to 7FFFFh, the IRON bit of the PRG2C register must be set to 1.
Please refer to the following FAQ for instructions on how to set the IRON bit to 1.
When debugging a program as described above, make sure you check select “Use with IRON (bit 1 of 000010H) set to 1 under the MCU Setting tab in the Emulator Setting dialog box.
The user program was executed immediately after downloading without issuing the reset command.
The stack pointer is not set to the correct value.
（For example, the stack pointer is not set at all, indicates an area that is not in RAM, etc.）
There is no E8/E8a stack space in the user stack area.
（E8/E8a operations require some open space in the stack area.）
The vector area isn’t set (regardless of whether interrupts will be used or not).
The user’s program is using the RAM area occupied by E8a (the emulator does not occupy the RAM area in some MCUs).
For more details concerning the area occupied by the E8a emulator, "Notes on Using the E8a Emulator" section in the E8a Emulator Additional Document for User’s Manual corresponding to the MCU group you are using in your system.
Download the E8a Emulator Additional Document for User’s Manual here.
Also, the RAM area occupied by E8a can be verified and changed when starting up the debugger using the firmware configuration tab in the [Emulator Setting] dialog box.
When using R8C with E8a, the following also applies:
In the start-up program (sect30.inc) created by the C compiler, the definitions specified in the variable vector table are disabled (.if 0) as the default. When an interrupt is used under these conditions, the program may jump to an unexpected address, generating a ILLEGAL INSTRUCTION error. To use interrupts that use variable vectors, make sure you enable the definitions in the vector table.