How to write interrupt service routine in TPUm (m=0 to 5) ?

hello sir,

I have done coding (below code) to use TPU5 timer to blink the LED0 with delay 100ms,

but I want to implement these with interrupt service routine.

so, how to code to enable these feature ?

___________________________________________________________________________

#include <Arduino.h>
char r=0;
void setup()
{
pinMode(PIN_LED0,OUTPUT);
TPU5.TCR.BIT.TPSC = 0b110;//timer pre-scalar clk/256
TPU5.TCR.BIT.CKEG = 0b01;//clock edge setting
TPU5.TCR.BIT.CCLR = 0b001;//counter clear on comapre match settings

TPU1.TMDR.BIT.MD = 0b0000;//set the timer mode for normal operation

TPU5.TIOR.BIT.IOA = 0b0000;//disable the timer I/O pin TIOCA5.....see page 1270 of datasheet
TPU5.TIOR.BIT.IOB = 0b0000;//disable the timer I/O pin TIOCB5......see page 1270 of datasheet

TPU5.TGRA = 0x927D; //set the counting period

//TPU5.TIER.BIT.TGIEA = 1; //enable the TPU5 interrupt

TPUA.TSTR.BIT.CST5 = 1;// start the timer
}

/*void INT_Excep_TPU5_TGI5A()
{
//digitalWrite(PIN_LED0,~digitalRead(PIN_LED0));
digitalWrite(PIN_LED0,HIGH);
}
*/
void loop()
{
if(TPU5.TSR.BIT.TGFA == 1)
{
TPU5.TSR.BIT.TGFA=0;
digitalWrite(PIN_LED0,r);
r=(~r);

}

}

  • I describe the code for using TPU5.

    -------------------------------------------

    Sketch.cpp

    -------------------------------------------

    /* GR-KAEDE Sketch Template V1.16 */

    #include <Arduino.h>

    #include "rx64m/interrupt_handlers.h"

    char r = 0;

    void setup()

    {

       pinMode(PIN_LED0, OUTPUT);

       startModule(MstpIdTPU0);

       TPU5.TCR.BIT.TPSC = 0b110; //timer pre-scalar clk/256

       TPU5.TCR.BIT.CKEG = 0b01; //clock edge setting

       TPU5.TCR.BIT.CCLR = 0b001; //counter clear on comapre match settings

       TPU1.TMDR.BIT.MD = 0b0000; //set the timer mode for normal operation

       TPU5.TIOR.BIT.IOA = 0b0000; //disable the timer I/O pin TIOCA5.....see page 1270 of datasheet

       TPU5.TIOR.BIT.IOB = 0b0000; //disable the timer I/O pin TIOCB5......see page 1270 of datasheet

       TPU5.TGRA = 0x927D; //set the counting period

       /* Set TGI6A interrupt priority level to 5*/

       IPR(TPU5,TGI5A) = 0x5;

       /* Enable TGI6A interrupts */

       IEN(TPU5,TGI5A) = 0x1;

       /* Clear TGI6A interrupt flag */

       IR(TPU5,TGI5A) = 0x0;

       SLIBXR133 = SLIBNO(TPU5,TGI5A);

       TPU5.TIER.BIT.TGIEA = 1; //enable the TPU5 interrupt

       TPUA.TSTR.BIT.CST5 = 1; // start the timer

    }

    void INT_Excep_PERIB_INTB133()

    {

    //digitalWrite(PIN_LED0,~digitalRead(PIN_LED0));

    digitalWrite(PIN_LED0,HIGH);

    }

    void loop()

    {

    /*

       if (TPU5.TSR.BIT.TGFA == 1)

               {

           TPU5.TSR.BIT.TGFA = 0;

           digitalWrite(PIN_LED0, r);

           r = (~r);

       }

    */

    }

    -------------------------------------------

    interrupt_handlers.cpp

    -------------------------------------------

    (snip)

    /* comment out

    void INT_Excep_PERIB_INTB133(void){

    // KAEDE

    #if UseTpu5

    INT_Excep_TPU5_TGI5A();

    #endif

    }

    */

    (snip)