Other Parts Discussed in Thread: TM4C1294NCPDT
Hello,
I'm using a tm4c1294xl launchpad. I'm trying to configure Timer 0 to run in periodic mode as a split 16 bits timer. When debugging, I saw that after IntEnable(INT_TIMER0A) the program jumps to the interrupt error handler although the timer is disable.This is the normal behavior? Please tell me what am I doing wrong.
#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c1294ncpdt.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
int main(void) {
uint32_t sysClock;
//configure sys clock
sysClock=SysCtlClockFreqSet((SYSCTL_OSC_MAIN|SYSCTL_XTAL_25MHZ|SYSCTL_USE_PLL|SYSCTL_CFG_VCO_320),40000000);
//enable peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//config gpio and timer0
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_0|GPIO_PIN_1);
TimerConfigure(TIMER0_BASE,TIMER_CFG_SPLIT_PAIR |TIMER_CFG_A_PERIODIC|TIMER_CFG_B_PERIODIC);
TimerLoadSet(TIMER0_BASE,TIMER_A,10000000);
TimerLoadSet(TIMER0_BASE,TIMER_B,20000000);
IntMasterEnable(); //activate processor interrupt
IntEnable(INT_TIMER0A);
IntEnable(INT_TIMER0B);
TimerIntEnable(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
TimerIntEnable(TIMER0_BASE,TIMER_TIMB_TIMEOUT);
//TimerEnable(TIMER0_BASE,TIMER_A);
TimerEnable(TIMER0_BASE,TIMER_BOTH);
/*IntEnable(INT_TIMER0A);
IntEnable(INT_TIMER0B);*/
while(1){
}
}
void Timer0AIntHandler(void)
{
TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
if (GPIOPinRead(GPIO_PORTN_BASE,GPIO_PIN_0))
{
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,0);
}else
{
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,1);
}
}
void Timer0BIntHandler(void){
TimerIntClear(TIMER0_BASE,TIMER_TIMB_TIMEOUT);
if (GPIOPinRead(GPIO_PORTN_BASE,GPIO_PIN_1))
{
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_1,0);
}else
{
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_1,2);
}
}