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 Basic Problem ??

Part Number: EK-TM4C1294XL


Hi all. I am new program for EK-TM4C1294 XL board. I study follow "Work Book TM4C1294.pdf". I want to use timer with interrupt to generate precision time. But when i run program, cpu can not jump into Timer Interrupt Service Rountie. My code is below. I am using IAR IDE with preprocessor parameter are 

"ewarm" and  "TARGET_IS_TM4C129_RA0"

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


/* Declaring Global Variables */
uint32_t sys_clock_hz;

/* Declaring Function Prototype */
void Timer_ISR(void);


int main(void)
{
	/* Configure system clock using external clock and PLL */
	sys_clock_hz = MAP_SysCtlClockFreqSet(SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480,
			120000000);

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
        
	/*	Configure led as output	*/
	GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_0);

	/*	Configure Timer with 100mS period	*/	
	TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
	TimerLoadSet(TIMER0_BASE,TIMER_A,(sys_clock_hz/10)-1);
	TimerIntRegister(TIMER0_BASE,TIMER_A,Timer_ISR);
	
        
        TimerIntEnable(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
	IntEnable(INT_TIMER0A);
        TimerEnable(TIMER0_BASE,TIMER_A);
        IntMasterEnable();
        
	/* Infinite Loop */
	while(1)
	{
	}
}


void Timer_ISR(void)
{
	/*	Clear the timer interrupt	*/
	TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);

	if(GPIOPinRead(GPIO_PORTN_BASE,GPIO_PIN_0))
	{
		GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,0x00);
	}
	else
	{
		GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,0xff);
	}
}

  • Help me please !!!
  • Hi,

    Did you added the file startup_ewarm.c to your project and modified it? You should add the name of your timer interrupt routine first as an external declaration, and then to modify the name of  the timer interrupt routine in interrupt vector array.

    Registering only (as you do) is not useful without changing the names in interrupt vectors array. ( you can skip this instruction, just modifying is enough).

  • Thanks for you reply. I will try this. Have a nice day bro !!!
  • As you've clearly made effort to understand & deploy the MCU's Timer - here's (past, working) code. (under StellarisWare)

    This all follows the good direction of friend Petrei - this code (also) prepared under IAR.   (code attempts to "illustrate & detail" the guidance Petrei provided.)

    1)   He's directed that you add your (specific) Timer vector to the EWarm Startup File:  (illustrated for you - just below)

    // External declarations for the interrupt handlers used by the application.
    //
    extern void Timer1BIntHandler(void);     // TAK 500uS    Note: this replaces the need to "register the interrupt" - proves quicker & easier!

    2)  You must then "enter" this interrupt w/in EWarm Startup "Vector Table."   (found w/in "EWarm Startup File")

    IntDefaultHandler,                                               // Timer 1 subtimer A     (this is the standard (default) handler
    Timer1BIntHandler,                                           // Timer 1 subtimer B     (I've named this one - "matches" your "External Declarations" (above)

    3)  Here's this timer's (sample) configuration code:

    // Timer_1B Init - 16 b (TAK Output)... via PD4)

    ROM_TimerDisable(TIMER1_BASE, TIMER_B);

    ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT);

    ROM_TimerLoadSet(TIMER1_BASE, TIMER_B, 25000); // 500uS

    ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMB_TIMEOUT);

    ROM_IntEnable(INT_TIMER1B);

    4) and here is the Interrupt service routine:

    // Services the T1_B interrupt // Tak Timer
    //
    void
    Timer1BIntHandler(void)
    {

    ROM_TimerIntClear(TIMER1_BASE, TIMER_TIMB_TIMEOUT);

    GPIO_PORTD_DATA_R &= ~0X10; // PD4 Lo TAK Out

    ROM_TimerDisable(TIMER1_BASE, TIMER_B);

    }