Internal reset request due to TRAP

Hi,

 

I am working on project with RL78/G13 with E2 studio and KPIT GNU Compiler.

Some times system resets due execution of TRAP instruction.

Any one have idea about why this happens.

 

  • RL78 does not have a TRAP instruction. RL78 has a TRAP interrupt vector.
    This is triggered by executing 0xFF as instruction code, which is an undefined instruction.
    This might be caused by
    - Jump to invalid address.
    - Execute an interrupt with an invalid or undefined interrupt vector.
    - Return from function with RETI or RETB instruction.
    - Return from interrupt with RET instruction.
  • My code consists of only one Interval Timer interrupt.
    No any other function present in my code.
    No any jump instruction like go to.
    still mcu resets and RESF flag indicates reset due to TRAP.
  • My code consists of only one Interval Timer interrupt.
    No any other function present in my code.
    No any jump instruction like go to.
    still mcu resets and RESF flag indicates reset due to TRAP.
  • Also, please make sure the RL78 CPU is being held in reset until VDD =/> minimum rated voltage, which depends on the CPU Mode and Speed you have set in Option byte 000C2H.  Sometimes if CPU is allowed to start with VDD too low, code execution can fail and fetch out-of-order instruction, like 0xFF opcode which is erased Code flash value, so TRAP results. 

    RL78 Voltage range limits:

     

    The easiest way to keep the RL78 CPU in reset is to turn on the LVD RESET mode in Option Byte 000C1H.  For example, if the Option byte 000C2H is set to 0xE8 (High Speed Mode, 32MHZ), then you must hold CPU in reset until VDD = 2.7Volt or higher.

    For LVD RESET setting to hold CPU in RESET until VDD = 2.7V, use 000C1H = 0x7F (VLVD5: reset on VDD = 2.75V falling edge) or higher setting than 2.75V

     

    Regards,

    Mike

  • Please check once if interal WDT setting is enabled (check in link options ,Option byte setting).If so that might be the reason .Please feed the internal WDT the internal reset will not occur
  • Reset by TRAP means it is a software crash in your application. Cause is illegal instruction execution.

    Every function call is a jump instruction.

    The easiest way to get illegal instruction execution is to use a "normal" function (means a function that does not use __attribute__ ((interrupt)) ) as interrupt function. In this case the interrupt function exit uses the wrong instruction, the stack is not read correctly, the return address is not found and the processor jumps to a wrong address.