Part Number: TM4C1290NCZAD
Hi experts,
During operation, they observed an issue where the program randomly stops running. The system can be recovered by power-cycling the board.
When this issue occurs, it also becomes impossible to connect via the JTAG debugger, and the following error message is displayed in the debug environment:
“CORTEX_M4_0: Error connecting to the target: (Error -2062 @ 0x0) Unable to halt device. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 8.0.27.9)”
As a result of our investigation, they found that the issue is resolved by stopping the timer once before updating the timer counter value, and then enabling it again afterward.
Specifically, they implemented the following Disable() / Enable() sequence:
TimerDisable(TIMER0_BASE, TIMER_A);
TimerLoadSet(TIMER0_BASE, TIMER_A, (wTimer - 1));
TimerEnable(TIMER0_BASE, TIMER_A);
Our questions are as follows:
- Q1: If the timer counter value is updated without stopping the timer, what kinds of malfunction or unexpected behavior could occur?
- Q2: From a design and specification point of view, is the above workaround of stopping and restarting the timer an appropriate solution?
The initialization code is shown below.
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER0));
TimerDisable(TIMER0_BASE, TIMER_A);
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
TimerPrescaleSet(TIMER0_BASE, TIMER_A, 0);
TimerLoadSet(TIMER0_BASE, TIMER_A, (g_timerPeriod -1) );
TimerUpdateMode(TIMER0_BASE, TIMER_A, TIMER_UP_LOAD_TIMEOUT);
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
IntPrioritySet(INT_TIMER0A, 4);
IntEnable(INT_TIMER0A);
TimerEnable(TIMER0_BASE, TIMER_A);
Best regards,
O.H