I'm having a problem while trying to run code on my TM4C123GH6PM. While running, It will almost immediately halt into IntDefaultHandler.
Do I have to call TimerIntRegister in addition to IntRegister? Even in spite of both of these, do I still have to manually put my function in the vector table in the startup file?
The weirdest part is, is that this code has worked flawlessly in the past, but only just now recently started having problems.
I've tried 3 different Launchpads and I'm still having the same issue. I could really use some help.
Sorry in advanced, I haven't posted here much. If there's any more info that's needed, I can provide that quickly.
/*CO2GridV2.3 * Ovie Onoriose */ //includes #include <stdint.h> // Variable definitions for the C99 standard. #include <stdio.h> // Input and output facilities for the C99 standard. #include <stdbool.h> // Boolean definitions for the C99 standard. #include "inc/tm4c123gh6pm.h" // Definitions for the interrupt and register assignments. #include "inc/hw_memmap.h" // Memory map definitions of the Tiva C Series device. #include "inc/hw_types.h" // Definitions o f common types and macros. #include "driverlib/sysctl.h" // Definitions and macros for System Control API of DriverLib. #include "driverlib/interrupt.h" // Defines and macros for NVIC Controller API of DriverLib. #include "driverlib/gpio.h" // Definitions and macros for GPIO API of DriverLib. #include "driverlib/timer.h" // Defines and macros for Timer API of DriverLib. #include "driverlib/pin_map.h" //Mapping of peripherals to pins for all parts. #include "driverlib/uart.h" // Definitions and macros for UART API of DriverLib. #include "driverlib/adc.h" // Definitions for ADC API of DriverLib. #include "driverlib/fpu.h" // Prototypes for the FPU manipulation routines. #include "driverlib/ssi.h" #include "stdarg.h" #include "driverlib/i2c.h" #include "driverlib/uart.h" #include "utils/uartstdio.h" // Prototypes for the UART console functions. //function prototypes void init_timer(void); //void output(void); void duty_cycle(void); void grid_eye(void); void setOpMode(int mode); void setFrameRate(int frame_rate); void thermistor(void); void initI2C(void); void sendI2C(int slave_addr, int data_amount, ...); int getI2C(int slave_addr, int reg); void init_UART(void); //variables #define TIMER_FREQ 1 #define UART_BAUDRATE 115200 #define SLAVE_ADDRESS 0x68 int sys_clock, start = 0, end = 0, duty = 0, x = 0, sum = 0, pix, temp[8][8] = {}, i, j, count; int main(void) { // Sets the system clock to run at 40 MHz SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); sys_clock = SysCtlClockGet(); init_UART(); init_timer(); initI2C(); UARTprintf("test\n"); setOpMode(0x00); setFrameRate(10); TimerEnable(TIMER1_BASE, TIMER_A); TimerEnable(TIMER0_BASE, TIMER_BOTH); count = 0; IntMasterEnable(); while(1); } void init_timer(void) { ///////////////////////////////////////// //////Timer for Grid-Eye///////////////// ///////////////////////////////////////// // Enable and configure Timer1 peripheral. SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // Configure as a 32-bit timer in periodic mode. TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC); // Initialize timer load register. TimerLoadSet(TIMER1_BASE, TIMER_A, sys_clock*TIMER_FREQ -1); // Registers a function to be called when the interrupt occurs. IntRegister(INT_TIMER1A, grid_eye); // The specified interrupt is enabled in the interrupt controller. IntEnable(INT_TIMER1A); // Enable the indicated timer interrupt source. TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); // TimerLoadSet(TIMER1_BASE, TIMER_B, sys_clock*2 -1); // IntRegister(INT_TIMER1B, output); // IntEnable(INT_TIMER1B); // TimerIntEnable(TIMER1_BASE,TIMER_TIMB_TIMEOUT); ////////////////////////////////////////// //////Timers for CO2 Sensor/////////////// ////////////////////////////////////////// // Enable and configure Timer0 peripheral. SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // Initialize timer A and B to count up in edge time mode TimerConfigure(TIMER0_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP | TIMER_CFG_B_CAP_TIME_UP)); // Timer a records pos edge time and Timer b records neg edge time TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE); TimerControlEvent(TIMER0_BASE, TIMER_B, TIMER_EVENT_NEG_EDGE); //set the value that the timers count to (0x9C3F = 39999) //CO2 sensor outputs 1khz pwm so with mcu at 40Mhz, timers should stay in sync with CO2 output TimerLoadSet(TIMER0_BASE, TIMER_BOTH, 0x9C3F); //Configure the pin that timer a and timer b read from //PB6 & PB7 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB6_T0CCP0); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_6); GPIOPinConfigure(GPIO_PB7_T0CCP1); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_7); // Registers a interrupt function to be called when timer b hits a neg edge event IntRegister(INT_TIMER0B, duty_cycle); // Makes sure the interrupt is cleared TimerIntClear(TIMER0_BASE, TIMER_CAPB_EVENT); // Enable the indicated timer interrupt source. TimerIntEnable(TIMER0_BASE, TIMER_CAPB_EVENT); // The specified interrupt is enabled in the interrupt controller. IntEnable(INT_TIMER0B); }