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.

TM4C129XNCZAD: One second delay using Timer in TM4C129XNZAD

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

Hi,

I am working on TM4C129XNZAD microcontroller, I want to apply one second delay using Timer concepts, can you please tell me how to implement the code or else share the sample code for one second delay with timer.

Thanks & Please help me on this, I am waiting for your reply.

  • Hi,

      There is an example for that. Please refer to:

    C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\timer\oneshot_16bit.c \\ This example shows how to configure Timer0B as a one-shot timer with a single interrupt triggering after 1ms.

    C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\timer\periodic_16bit.c \\ This example shows how to configure Timer0B as a periodic timer with an interrupt triggering every 1ms.

    Also another timer example can be found in C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\timers.

  • Hi,

    Thanks for the reply.

    I am asking one second delay example code.

  • Hi Charles,

    Can you please help me, I want to implement Timer with Interrupt  of some second delay. How to implement it, please tell me. I am new to this controller. Please suggest some sample code or else share me some code related to my task.

    Thanks a lot for helping me.

  • Hi,

      Did you go through the example C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\timers that I listed in my last reply? It is doing exactly what you need - to generate a 1 second delay. Why don't you go through the code to see how the two timers are configured to generate a 1 second and half-second interrupts. Below is the snippet.

        //
        // Enable the GPIO port that is used for the on-board LEDs.
        //
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    
        //
        // Enable the GPIO pins for the LEDs (PN0 & PN1).
        //
        MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
    
        //
        // Enable the peripherals used by this example.
        //
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    
        //
        // Enable processor interrupts.
        //
        MAP_IntMasterEnable();
    
        //
        // Configure the two 32-bit periodic timers.
        //
        MAP_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
        MAP_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
        MAP_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock);
        MAP_TimerLoadSet(TIMER1_BASE, TIMER_A, g_ui32SysClock / 2);
    
        //
        // Setup the interrupts for the timer timeouts.
        //
        MAP_IntEnable(INT_TIMER0A);
        MAP_IntEnable(INT_TIMER1A);
        MAP_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
        MAP_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
    
        //
        // Enable the timers.
        //
        MAP_TimerEnable(TIMER0_BASE, TIMER_A);
        MAP_TimerEnable(TIMER1_BASE, TIMER_A);