I am trying to reconfigure WTimer0 on the fly. Basically I have a GUI and I want to click a button and have the ARM change it's timing intervals say from 10Hz to 100Hz etc.... I've gotten this running with the below code and it works fine for the first or second configuration message, but after that it just stops. Is it possible to stop the timer, change the TAILR register with the TimerLoadSet command and then run TimerEnable(); to start it or do I have to use the match registers or something else? I don't seem to be able to configure the timer, start it and then change it on the fly in the manner I have coded up. Below is the code I'm using to configure and start/stop the WTimerA module.
To configure initially and reconfigure the timer I am re-running the same function:
void WTimer0A_32bit_config(uint32_t counter)
{
// Disable Timer peripheral
//SysCtlPeripheralDisable(SYSCTL_PERIPH_WTIMER0);
//SysCtlDelay(1000);
// Enable Timer peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
// Configure WTimer0 in 32-bit mode
TimerConfigure(WTIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC_UP);
// load timer with SysClk/100 (1mS increments)
TimerLoadSet(WTIMER0_BASE, TIMER_A, counter);
// Enable timer interrupt in master interrupt controller
IntEnable(INT_WTIMER0A);
// Enable interrupts
TimerIntEnable(WTIMER0_BASE, TIMER_TIMA_TIMEOUT);
// Register ISR
TimerIntRegister(WTIMER0_BASE, TIMER_A, *WTimer0IntHandler);
}
Function to start the timer:
TimerEnable(WTIMER0_BASE, TIMER_A);
Function to stop the timer:
TimerDisable(WTIMER0_BASE, TIMER_A);
I've tried many many different variations of all of these form initially configuring it and just changing the TAILR register to disabling and re-enabling the peripheral every time. I don't understand why this works fine once or twice, but then the timer just stops. I've taken screen shots and compared all of the bits in the WTimer0 registers when it is running and when it fails and I don't see any difference. The bit values in all the registers are the same when it fails and when it is running. Is there something I'm not re-enabling in the interrupt controller? Thanks for any input.