I want to configure MTU3 as compare match timer but it is not generating interrupt.
Timer initialisation and MTU3 ISR function is as below:
/* 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;
/* Start MTU3 TCNT counter */
MTU.TSTRA.BIT.CST3 = 0x1;
// MTU0 TGID0
static int count;
/* Toggle LEDs */
LED0 = (uint8_t) ~LED0;
LED1 = (uint8_t) ~LED1;
LED2 = (uint8_t) ~LED2;
LED3 = (uint8_t) ~LED3;
Thanks & regards,
Instantiating your count variable inside your ISR may be your issue.
count is incremented so that 1 sec time delay is there between each LED toggle.
MTU3 ISR itself is not getting executed.
TCNT is incrementng but still interrupt is not fired.
The software looks good.Does interrupt request for TGIB3 occure?Did you enable interrupts in PSW?Is the interrupt vector correctly set?
Thank you frankL
interrupt vector table was the problem.