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.

EK-TM4C1294XL timer query

Other Parts Discussed in Thread: EK-TM4C1294XL

Dear All,

I am programming the EK-TM4C1294XL. I am using the timer.c example from the list of examples provided by TI. The timer in that example has an interrupt of 1seconds. I was aimiing to have the timer interrupt at every 4 microsecond. The minimum interrupt time I was able to achieve was 2.3 ms. 

Can anyone please explain how why this is the case and how I can achieve lower interrupt time ?

Thanks in advance

  • Hello Khalid

    Can you please share the code which is giving an interrupt at 2.3ms instead of expected 4 us?

    Regards
    Amit
  • Hello Amit,

    I set the clock at 12 MHz from the following code :

    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);
    I configure the timer as usual... I then set the load value of the timer as :

    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, 480 ); g_ui32SysClock/

    If I use the above line as follows, then the interval is 1 second

    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock );

    thanks

    Khalid
  • Hello Amit,

    Sorry I made some mistakes in my last post, so posting again after correction :

    I set the clock at 120 MHz from the following code :

    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);
    I configure the timer as usual... I then set the load value of the timer as :

    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, 480 );

    If I use the above line as follows, then the interval is 1 second

    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock /2);

    thanks

    Khalid
  • Hello Khalid

    Setting the timer load to g_ui32SysClock /2 would not be 1 second but 0.5 sec

    Setting the timer load to 480 will produce a timer interval of 4us. But then how are you toggling the pin, via interrupt?

    Regards
    Amit
  • Hi Amit.

    Yes that's right, it will be 0.5 s.

    I am toggling the pin via interrupt. The code is given below :

    void
    Timer0IntHandler(void)
    {
    //
    // Clear the timer interrupt.
    //
    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

    //
    // Toggle the flag for the first timer.
    //
    HWREGBITW(&g_ui32Flags, 0) ^= 1;

    //
    // Use the flags to Toggle the LED for this timer
    //
    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, g_ui32Flags);

    //
    // Update the interrupt status.
    //
    ROM_IntMasterDisable();
    ROM_IntMasterEnable();

    }
  • Hello Amit,

    Will it be possible for you to send some pre-tested code to achieve this ? If yes, could you please share it ?

    Regards,
    Khalid
  • Hello Khalid

    You do not need to do the following

    //
    // Toggle the flag for the first timer.
    //
    HWREGBITW(&g_ui32Flags, 0) ^= 1;

    //
    // Use the flags to Toggle the LED for this timer
    //
    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, g_ui32Flags);

    //
    // Update the interrupt status.
    //
    ROM_IntMasterDisable();
    ROM_IntMasterEnable();

    Instead it can be made as.

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, ~(GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_0)));

    Regards
    Amit
  • I have tried using the code you suggested but the issue still persists...not sure why

    Regards,
    Khalid
  • Hello Khalid,

    Does the code have the UARTprintf in it?

    Regards
    Amit
  • Hi Amit,

    Ah yes, it has the UART printf in it..

    Regards,
    Khalid