In our code, we set up SysTick as shown.
/* Init the SysTick module for 1ms interrupts @50 MHz.
*/
ROM_SysTickPeriodSet(50000000 / 1000);
ROM_SysTickIntEnable();
ROM_SysTickEnable();
The SysTick_handler routine is shown below.
void SysTick_handler(void)
{
/*
* === FUNCTION ======================================================================
* Name: Systick_handler()
* Description: Interrupt Service Routine for the systick.
*
* Handle all background processing.
* =====================================================================================
*/
sc_tmr_ms_ticked = true;
++tmr_ctr;
//
// The systick is 1mS - we want to poll the buttons every BUTTON_POLL_TIME mS.
//
if ((tmr_ctr % BUTTON_POLL_TIME) == 0) {
STbutton_poll();
}
// Check the wdog every 50msec. The output should be toggled.
if ((tmr_ctr % WDOG_POLL_TIME) == 0) {
wdog_check();
}
// poll the SAFETY_FAULT input
if ((start_the_main_loop == true) && ((tmr_ctr % SAFETY_FAULT_POLL_TIME) == 0)) {
safety_fault_poll();
}
// if ((tmr_ctr % WIRELESS_POLL_TIME) == 0) {
// read_BT_stat();
// }
//
// if ((tmr_ctr % WIRELESS_BATT_POLL_TIME) == 0) {
// read_BT_batt_stat();
// }
if (((proc.handpiece_state == LED_FAST_FLASH) && ((tmr_ctr % FAST_FLASH_RATE) == 0)) ||
((proc.handpiece_state == LED_SLOW_FLASH) && ((tmr_ctr % SLOW_FLASH_RATE) == 0)) ||
((proc.handpiece_state == LED_FASTER_FLASH) && ((tmr_ctr % FASTER_FLASH_RATE) == 0))) {
/**/
//proc.handpiece_on ^= 1; // flip status led
// Synchronize flashing of this LED
if (((proc.handpiece_state == LED_FAST_FLASH) && ((tmr_ctr % (FAST_FLASH_RATE*2)) == 0)) ||
((proc.handpiece_state == LED_FASTER_FLASH) && ((tmr_ctr % (FASTER_FLASH_RATE*2)) == 0)) ||
((proc.handpiece_state == LED_SLOW_FLASH) && ((tmr_ctr % (SLOW_FLASH_RATE*2)) == 0)))
proc.handpiece_on = 1;
else
proc.handpiece_on = 0;
if (proc.handpiece_on) {
SC_RAISE_EVT(Handpiece_led, on);
} else {
SC_RAISE_EVT(Handpiece_led, off);
}
}
/* more LED processing, all using the same code as above */
}
Here's the PROBLEM. The code runs fine until some event occurs and SysTick_handler stops being called. Our box stops processing input from buttons and stops flashing LEDs. Using the debugger, I see that the main loop is still running, but no call to SysTick_handler.
- I am up to image 150. As I change to a new image, sometimes the failure disappears, and sometimes it appears at another place in the sequence. If it appears, it is repeatable in that image.
- I can monitor the SysTick Interrupt enable bit and Master Interrupt enable bit(PRIMASK register), and both levels of interrupt are enabled.
- This box has a USB connection, and we use code built from TivaWare 2.1.2.111.
- If a USB cable is connected, the failure doesn't happen. It only happens if no cable is connected.
- If I plug in a cable after the failure occurs, the code starts running again.
- I changed the code to pull in 2.2.0.295 libraries, but that did not fix the problem.
- My STACK_SIZE = 2048. I bumped it up by 512 to 2560, but that did not fix the problem.
Has this issue been seen by anyone else? It's clearly tied to the USB interface, but I can't figure out why SysTick_handler stops being called, so I can't fix the problem. I have workarounds available, but they will not be fully accepted if I can't point to the actual failure mechanism.