I’m writing an application for a programmable S2B which in one configuration needs to sleep the radio during initialization (before entry into the main for loop). I’m seeing the application freeze inside the sys_xbee_tick() function. I traced it to the processing of a modem status == joined (2) message which calls the internal handler. The handler never returns. The handler basically sends a bunch of AT command queries to the EM250. Since the watchdog doesn’t reset the CPU, I’m assuming it is stuck inside the loop in the xbee_ser_write function waiting for the bytes to go to the EM250’s UART, but the radio is sleeping. As far as I can tell, this is the only loop that resets the watchdog timer, from xbee_serial_hcs08.c, line 183 and onward:
case SERIAL_PORT_SCI2: // EM250
while (length--)
{
// SCI2S1_TDRE -- 0 = sending, 1 = ready for byte
// PTDD_PTDD6 -- 0 = clear to send, 1 = not clear
while (! SCI2S1_TDRE || PTDD_PTDD6)
{
__RESET_WATCHDOG();
}
SCI2D = *((const byte FAR *)buffer)++;
}
break;
How do I prevent the joined message from triggering this freeze?