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.

REG: Timer interrupt generation in TM4C123GH6PM Launchpad

Other Parts Discussed in Thread: TM4C123GH6PM, EK-TM4C123GXL

Hai;

I am using TM4C123GH6PM Launchpad, i am try to generate a general purpose timer interrupt with 25 ms interval. plz anyone help to me, i am new to one for this. Possible to provide a sample program for my application.

Thanks in advance

Yuvaraj

  • Hello Yuva,

    Did you look at the "timer" example in the folder "<TivaWare_Install_Folder>/examples/boards/ek-tm4c123gxl/timers"?

    Thanks,
    Sai
  • Thank you sai,

  • Hai

    I am tried with given example but the generated interrupt not service inTimerB0IntHandler routine,
    the generated interrupt goes to tm4c123gh6pm_startup_ccs.s file and service the static void IntDefaultHandler function.
    plz help to solve this, how to configure timer0B interrupt handler. I am found this error via debugging the code and I am attached my
    code and error screen shot also. If anything i am configured wrong plz denote it.

    I am using TI Tiva C series (TM4C123GH6PM)Launch Pad.

    #include <stdbool.h>
    #include <stdint.h>
    //#include "inc/hw_ints.h"
    #include "inc/tm4c123gh6pm.h"

    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"


    volatile uint32_t g_ui32Counter = 0;

    //*****************************************************************************
    //
    // Configure Timer0B as a 16-bit periodic counter with an interrupt every 1ms.
    //
    //*****************************************************************************
    int main(void)
    {
             uint32_t ui32PrevCount = 0;
             SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);


    // Configure Timer0B as a 16-bit periodic timer.
    TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PERIODIC);


    // Set the Timer0B load value to 1ms.
    TimerLoadSet(TIMER0_BASE, TIMER_B, SysCtlClockGet() / 1000);


    // Enable the Timer0B interrupt on the processor (NVIC).
    IntEnable(INT_TIMER0B);


    // Enable Timer0B.
    TimerEnable(TIMER0_BASE, TIMER_B);


    // Enable processor interrupts.
    IntMasterEnable();


    // Configure the Timer0B interrupt for timer timeout.
    TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

    // Initialize the interrupt counter.
    g_ui32Counter = 0;

    // Loop forever while the Timer0B runs.
    while(1)
    {
                  // If the interrupt count changed, print the new value
                 if(ui32PrevCount != g_ui32Counter)
                {
                        ui32PrevCount = g_ui32Counter;
                 }
    }

    }

    //*****************************************************************************
    //
    // The interrupt handler for the Timer0B interrupt.
    //
    //*****************************************************************************
    void Timer0BIntHandler(void)
    {
                  // Clear the timer interrupt flag.
                   TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
                  // Update the periodic interrupt counter.
                   g_ui32Counter++;

    }

  • Screenshot from "Interrupt Controller" chapter in "TivaWare Peripheral Driverlib User's Guide"

    So add your interrupt handler to the interrupt vector table in the startup code.

    Thanks,

    Sai

  • Thank you Sai..    Its working..