INT0 malfunction in RL78/G12 30 PIN device

RL78/G12 30 PIN device

In my hardware design I have square wave signal derived from supply mains for frequency computations.

I have configured Timer ch0 for 1ms ints for time period computations.

I have configured INTO for falling edge interrupts(level1 prio) and wants to capture time(ms) for 10 successive ints.

But my INT0 occurs randomly.

Enabling ms counting in first FE INT0 interrupt and stopping at 10th FE interrupt.

I get randomly changing counts in ms timer.


Used code generator for Timer0 and INT0 configurations.

I Have Timer0 running properly for 7 segment multiplexing with highest priority.


anybody experienced similar issues?




  • Hi Vinod,

    As what I have read from your statement, you're using the square wave signal derived from supply mains as trigger for INT0? Am I right? Have you check the quality of the square wave signal? Maybe it's giving false trigger. If I didn't guessed it correctly, maybe you could explain more your setup so that the forum can help you more with your issue. Hoping your issue will be resolved asap, thanks!

    RenesasRulz Forum Moderator
  • In reply to JB:

    Yes You have understood my issue right.

    yes checked the signal quality on the oscilloscope and found it very good.

    For a ten cycle duration - it counts very small nos and hence false trigger may not be the case.

    I could single step the program and found the logic working fine.


    Its observed that Hz_Interval var has values like 10,80, 20,40,11 randomly after counting down 10 cycles.

    Timer0 is set with highest pririty.

    The square wave signal is derived from a comparator with sharp edges, hysterysis and found perfect on the scope.

    When port pin is set as input and sampled at every ms ISR, I am able to get freq properly.Implemented software FE sensing and cycle counting. But this is not what i want.

    Tried setting the port pin as input as well as unused - the INTP0 behaves the same way.  

    // sample code

    void R_INTC_Create(void)


       PMK0 = 1U;    /* disable INTP0 operation */

       PIF0 = 0U;    /* clear INTP0 interrupt flag */

       PMK1 = 1U;    /* disable INTP1 operation */

       PIF1 = 0U;    /* clear INTP1 interrupt flag */

       PMK2 = 1U;    /* disable INTP2 operation */

       PIF2 = 0U;    /* clear INTP2 interrupt flag */

       PMK3 = 1U;    /* disable INTP3 operation */

       PIF3 = 0U;    /* clear INTP3 interrupt flag */

       PMK4 = 1U;    /* disable INTP4 operation */

       PIF4 = 0U;    /* clear INTP4 interrupt flag */

       PMK5 = 1U;    /* disable INTP5 operation */

       PIF5 = 0U;    /* clear INTP5 interrupt flag */

       /* Set INTP0 level 2 priority */

       PPR10 = 1U;

       PPR00 = 0U;



    //====Initiate TM capture process =========================

    Hz_Interval = 0; // capture interval

    Adc_Flags.Hz_Cap_ON = FALSE;

    Cycle_Counts =0; // capture timings for 10 cycles

    R_INTC0_Start(); // enable INTO frm Hz IN


    __interrupt static void r_intc0_interrupt(void)


       /* Start user code. Do not edit comment generated here */

       // start INT0 in main signal capture

       // on first INT start timing capture

    if (!Adc_Flags.Hz_Cap_ON) // initiate time period capture on first FE,  if not started


    Adc_Flags.Hz_Cap_ON = TRUE;

    Cycle_Counts =10; // capture timings for 10 cycles

    Hz_Interval =0;




    if (!--Cycle_Counts)


    Adc_Flags.Hz_Cap_ON = FALSE; // stop time  period capture

    R_INTC0_Stop(); // no more HZ ints required



       /* End user code. Do not edit comment generated here */


    //==Counting millisecs in Timer0 ISR===================================

    if (Adc_Flags.Hz_Cap_ON)  



  • In reply to Vinod:


    Have you resolved your issue?

    Mike Clements
    RenesasRulz Moderator
  • In reply to Vinod:

    This thread will be archived due to inactivity.

    Mike Clements
    RenesasRulz Moderator