This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294NCPDT: Timer doesn't work as expected

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL

I have configured the Timer0 as 64 bit and working in periodic mode. However, the results look like I can only configure the time for the first time to enter the TimerA_IntHandler function. After that, I cannot control the time to enter the TimerA_IntHandler at all. It is always entered the interruption as fast as possible. I wonder if there is any actions which need to be done in the TimerA_IntHandler function so the periodic mode can be continued? Or did I do something wrong in the timer configuration? Thanks. 

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

// Configure the Timer.

void ConfigureTimer(void){

     //=================  timer 0 config  64-bit timers =================

         SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

         // Configure the  64-bit periodic timers

         TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);

 

        // Setup the interrupts for the timer timeout.

        TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

        TimerIntRegister(TIMER0_BASE, TIMER_A,TimerA_IntHandler);

  

        TimerEnable(TIMER0_BASE, TIMER_A);

        TimerLoadSet64(TIMER0_BASE, 100000000); // x SEC

}

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

  • It is always entered the interruption as fast as possible.

    Your description suggests that the interrupt flag is not cleared. You must clear the interrupt flag before you exit the ISR or otherwise it will re-enter the ISR immediately because the interrupt is still pending from the timer module. Take a look at the below two examples where the first thing in the ISR is to clear the timer interrupt flag. 

    C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\timers\timers.c

    C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\timer\periodic_16bit.c

  • Indeed, I forgot to clear the interrupt flag. Many thanks for point it out!