Hello,
I'm developing an application on the concerto ControlCARD (F28M35H52C1) and I'm having trouble with the UART when I have a timer interrupt trigger. When I comment out the TimerEnable function, the UART runs fine. Any ideas? Here's my code for the UART and timers.
// global variable for timer static unsigned long g_dwTickCounter50mS = 0; static unsigned long g_dwTickCounter1mS = 0;
// within main function
unsigned long dwOldTickCounter1ms = 0;
// Initialize the UART.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
GPIOPinConfigure(GPIO_PE4_U0RX);
GPIOPinConfigure(GPIO_PE5_U0TX);
// Enable the Watchdog Timer
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
//
// Enable the system timers
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
// Configure the two 32-bit periodic timers.
TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet(SYSTEM_CLOCK_SPEED)/10000);
TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet(SYSTEM_CLOCK_SPEED)/5);
// Setup the interrupts for the timer timeouts.
IntEnable(INT_TIMER0A);
IntEnable(INT_TIMER1A);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
// stall the timers during a breakpoint
TimerControlStall(TIMER0_BASE, TIMER_A, true);
TimerControlStall(TIMER1_BASE, TIMER_A, true);
// configure the watchdog timer
WatchdogResetEnable(WATCHDOG0_BASE);
WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet(SYSTEM_CLOCK_SPEED)*2); // 2 second timeout
WatchdogStallEnable(WATCHDOG0_BASE);
// Enable the timers.
TimerEnable(TIMER0_BASE, TIMER_A);
TimerEnable(TIMER1_BASE, TIMER_A);
// Enable the watchdog timer
WatchdogEnable(WATCHDOG0_BASE);
UARTStdioInit(0);
UARTprintf("UART Operating\n");
while(1)
{
// *** 200Hz loop ***
if((g_dwTickCounter1mS - dwOldTickCounter1mS) > 5)
{
// save the 1 msec counter value
dwOldTickCounter1mS = g_dwTickCounter1mS;
}
UARTprintf("Program in while loop\n");
// reload the watchdog
WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet(SYSTEM_CLOCK_SPEED)*2); // 2 second timeout
}
//********************************************
// timer interrupt handlers
//*****************************************************************************
//
// The interrupt handler for the first timer interrupt.
//
//*****************************************************************************
void
Timer0IntHandler(void)
{
// Clear the timer interrupt.
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
// Toggle the flag for the first timer.
HWREGBITW(&g_ulFlags, 0) ^= 1;
// hit the watchdog
watchDogHit();
// increment the time counter
g_dwTickCounter1mS++;
}
//*****************************************************************************
//
// The interrupt handler for the second timer interrupt.
//
//*****************************************************************************
void Timer1IntHandler(void)
{
// Clear the timer interrupt.
TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
// increment the time counter
g_dwTickCounter50mS++;
}
inline void watchDogHit(void)
{
static uint8_t extWD = 0;
// hit the external timer
extWD ^= 1;
}
//Print out from UART Terminal: UART Operating üððüþøüüÿüÿ
The UART garbage output happens after the timer interrupt occurs and then the application is unresponsive.
I appreciate your help.
Thanks,
Will