Greetings
I'm using 2 interrupts, one with button and other with timer, so far i've been managing to interrup with the button and seeing at the UART. When i added the TimerInterrupt, the UART stopped working and when i reset it won't start all over. I need to use LMFlasher and then upload the code.
Ill place the code here so someone find anything i should, or shouldn't do.
Again im using the TM4C123GXL launchpad.
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "driverlib/buttons.h"
#include "driverlib/adc.h"
#include "driverlib/timer.h"
#include "math.h"
#include "driverlib/ssi.h"
#define LED_RED 0x02 //PF1(Red)
#define LED_BLUE 0x04 //PF2(Blue)
#define LED_GREEN 0x08 //PF3(Green)
int count =0;
int cog=11;
unsigned long ulPeriod, rpm;
extern void IntGPIOF(void);
extern void Timer1IntHandler(void);
void Init (void){
ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
HWREG (GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG (GPIO_PORTF_BASE + GPIO_O_CR) |= GPIO_PIN_0;
HWREG (GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_M;
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 |GPIO_PIN_3);
}
void InitTimer (void) {
ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
ulPeriod = (ROM_SysCtlClockGet()) ;
ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, ulPeriod -1);
// Enable interruption Timer 1
IntEnable(INT_TIMER1A);
ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
ROM_TimerEnable(TIMER1_BASE, TIMER_A);
//ROM_IntMasterEnable();
}
void InitButtonInt (void){
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
GPIOIntDisable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_RISING_EDGE);
GPIOIntClear(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
GPIOIntRegister(GPIO_PORTF_BASE,IntGPIOF);
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4);
IntMasterEnable();
}
void InitUart (void) {
// UART Initialization
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioConfig(0, 115200, 80000000);
}
int main(void)
{
//volatile int ulLoop;
Init();
InitUart();
InitButtonInt();
InitTimer();
while(1)
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, LED_RED);
UARTprintf("RPM = %4d: ", rpm);
//SysCtlDelay(40000000);
}
}
void IntGPIOF(void)
{
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);
count++;
UARTprintf("Count = %4d \n", count);
}
void Timer0IntHandler(void)
{
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
}
void Timer1IntHandler(void)
{
rpm=count*60/cog;
count=0;
UARTprintf("Interrupcao = %4d \n", count);
TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
}
In the startup i have the timers well defined
void ResetISR(void);
static void NmiSR(void);
static void FaultISR(void);
static void IntDefaultHandler(void);
void Timer0IntHandler (void);
void Timer1IntHandler (void);
void IntGPIOF(void);
Timer0IntHandler, // Timer 0 subtimer A
IntDefaultHandler, // Timer 0 subtimer B
Timer1IntHandler, // Timer 1 subtimer A
IntDefaultHandler, // Timer 1 subtimer B
IntDefaultHandler, // Timer 2 subtimer A
IntDefaultHandler, // Timer 2 subtimer B
IntDefaultHandler, // Analog Comparator 0
IntDefaultHandler, // Analog Comparator 1
IntDefaultHandler, // Analog Comparator 2
IntDefaultHandler, // System Control (PLL, OSC, BO)
IntDefaultHandler, // FLASH Control
IntGPIOF, // GPIO Port F
What would be the cause. And i know i have libraries included that i don't need.