Why is FXT009 rebooting when USB is plugged out and then in?

Hi I have an application that run on the FXT009. It runs stably. I unplug the USB port and it still runs OK. BUT when I plug the USB back in, it restarts. I have attached screenshots of the trace and the back trace.

[attachment=1]Trace.png[/attachment]
[attachment=0]Back trace.png[/attachment]

Can anyone shed some light on this for me please? Or direct me to how I can resolve this.
Thanks,

Karl

Here is the reduced program than exhibits the same problem as above.

#include "adl_global.h"
#include "generated.h"
#include "adl_traces.h"

bool simOkFlag = FALSE;
bool serial_open = FALSE;
adl_tmr_t *appTmrHld;

s8 looprate = 100;


void SetNextMainLoopTimer(u32 RateMS);
void appMainloop(void);
void main_task(void);
void simEventHandler(u8 ev);


void main_task(void)
{
	TRACE((1, "APP: main_task..."));
	adl_simSubscribe ((adl_simHdlr_f)simEventHandler, NULL );
	appMainloop();
}

void appMainloop(void)
{
	s8 newlooprate = -1;
    if(simOkFlag == FALSE)
    {
    	TRACE((1, "APP: Waiting for SIM init..."));
    	newlooprate = 100;
    }

    SetNextMainLoopTimer(newlooprate);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SIM management routines

void simEventHandler(u8 ev)
{
   // s8 status;

    switch(ev){
    case ADL_SIM_EVENT_PIN_OK:
        TRACE((1, "APP: simEventHandler: ADL_SIM_EVENT_PIN_OK"));
        break;
    case ADL_SIM_EVENT_FULL_INIT:
    	TRACE((1, "APP: simEventHandler: ADL_SIM_EVENT_FULL_INIT"));
        simOkFlag = TRUE;
        break;
    default:
    	TRACE((1, "APP SIM: Unhandled event: %d", ev));
    }
}

void mainTimerHandler ( u8 ID, void *context )
{
	appMainloop();
}

void SetNextMainLoopTimer(u32 RateMS)
{
	if (appTmrHld != NULL && looprate != RateMS)
	{
		TRACE((1, "APP: Stopping current timer."));
		adl_tmrUnSubscribe(appTmrHld, mainTimerHandler, ADL_TMR_TYPE_100MS);
	}

	if (looprate != RateMS && RateMS != -1)
	{
		appTmrHld = adl_tmrSubscribe(TRUE, RateMS /100, ADL_TMR_TYPE_100MS, mainTimerHandler);
		looprate = RateMS;
	}
	else if (RateMS == -1)
	    TRACE((1, "APP: Going to sleep"));
}

Any ideas?

Thought I would give my conclusions for anyone else trying to figure this out…

This seems to be related to the module being in development mode. It only happens if at the time I am connected to it from developer studio…