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: Timer0IntHandler

Part Number: TM4C1294NCPDT

Dear Sir,

I'm not sure why Timer0 is not working. It's look like code didn't run to line 111 in main.c 

Please refer to pic1, pic2 and main.c  as attached. Do I missing some setting ? Kindly please advise. Thank a lot. 

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/gpio.h"

uint32_t g_ui32Flags;
uint8_t Timer_100mS=0;

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;
    Timer_100mS = 1;

    //
    // Update the interrupt status on the display.
    //
    /*
    ROM_IntMasterDisable();
    if( g_ui32Flags )
    {
        ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0);
        ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0);
    }else
    {
        ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);
        ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_PIN_1);
    }

    ROM_IntMasterEnable();
    */
}

/**
 * main.c
 */
int main(void)
{
    uint32_t ui32SysClock;
    uint8_t test_Flags;

    //
    // Run from the PLL at 120 MHz.
    //
    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
                                           SYSCTL_CFG_VCO_480), 120000000);

    //
    // Enable the peripherals used by this project.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);

    ROM_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_0);
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_1);
    ROM_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_1, GPIO_PIN_1);

    ROM_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0);
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_1);
    ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1, GPIO_PIN_1);

    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1, 0);

    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    ROM_GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1, 0);

    //
    // Enable processor interrupts.
    //
    ROM_IntMasterEnable();

    ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
    //ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ui32SysClock/1000); // 1mS
    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ui32SysClock/10); // 100mS

    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

    ROM_IntEnable(INT_TIMER0A);
    ROM_TimerEnable(TIMER0_BASE, TIMER_A);

    //
    // Loop forever while the timers run.
    //
    while(1)
    {
        if( Timer_100mS )
        {
            Timer_100mS = 0;
        }

        if( test_Flags )
        {
            test_Flags = 0;
            ROM_GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_PIN_0);
            ROM_GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_1, 0);
        }else
        {
            test_Flags = 1;
            ROM_GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_0, 0);
            ROM_GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_1, GPIO_PIN_1);
        }
    }
}

BR,

CCphi