Hi, I want to configure MTU3 as compare match timer but it is not generating interrupt. Kindly help. Timer initialisation and MTU3 ISR function is as below: void init_timer(void) { /* Protection off */ SYSTEM.PRCR.WORD = 0xA503; /* Cancel the MTU3 module clock stop mode */ MSTP_MTU3 = 0x0; /* Protection on */ SYSTEM.PRCR.WORD = 0xA500; /* Clock PCLKA/4=24MHz, count at falling edge, TCNT cleared by TGRB compare match */ MTU3.TCR.BIT.TPSC = 0x1; MTU3.TCR.BIT.CKEG = 0x1; MTU3.TCR.BIT.CCLR = 0x2; /* Operate timers in normal mode */ MTU3.TMDR1.BIT.MD = 0x0; /* TRGB compare match */ MTU3.TIORH.BYTE = 0x00; /* Set a period of 500 us */ MTU3.TGRB = 12000; IPR(MTU3,TGIB3)=0x07; IEN(MTU3,TGIB3)=0x1; IR(MTU3,TGIB3)=0x0; MTU3.TIER.BIT.TGIEB=0x1; /* Start MTU3 TCNT counter */ MTU.TSTRA.BIT.CST3 = 0x1; } // MTU0 TGID0 void INT_Excep_MTU3_TGIB3(void) { static int count; count++; if (count==2000) { count=0; /* Toggle LEDs */ LED0 = (uint8_t) ~LED0; LED1 = (uint8_t) ~LED1; LED2 = (uint8_t) ~LED2; LED3 = (uint8_t) ~LED3; } } Thanks & regards, Prija Nair.
↧