[BitCloud] IRQ and wake up problem

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all!

My problem is like this (BitCloud v.13):

I have coordinator and one end device which sleeps 10 seconds and is awake for 3 seconds.

Problem is that end device can't wake up on external interrupt (IRQ_6) well sometimes it wakes up and does what it has to do (send messasge, read sensor,...) but other times
it doesn't wake up on IRQ but does all the work after ZDO_WakeUpInd() is called , so I receive message(information) up to 10 seconds late.

When end device is awake and interrupt occurs everything works as expected.

Here is code:

Main task handler:

case APP_WAIT_STATE:
{
	if(IRQ_6)
	{
		// do things here


		// go to APP_SLEEP_STATE	
	}
	else
	{
		HAL_StartAppTimer(&sleepTimer);
	}

}
break;






case :	APP_WAKE_UP_STATE
{	
	wakeUpReq.ZDO_WakeUpConf = ZDO_WakeUpConf;
	ZDO_WakeUpReq(&wakeUpReq);
}
break;



case APP_SLEEP_STATE:
{
	sleepReq.ZDO_SleepConf = ZDO_EndDeviceSleepConf;	
	ZDO_SleepReq(&sleepReq);
}
break;







//**********************************************************************************
// IRQ_6_interrupt()
//**********************************************************************************
static void IRQ_6_interrupt(void)
{
	INT_6 = true;

	if(sleep)
	{
		appState = APP_WAKE_UP_STATE;
	}
	else 
	{
		HAL_StopAppTimer(&sleepTimer); 
		appState = APP_WAIT_STATE; 			
	}
	
	SYS_PostTask(APL_TASK_ID);
}


//************************************************************************************
// ZDO_WakeUpConf()
//************************************************************************************
static void ZDO_WakeUpConf(ZDO_WakeUpConf_t *conf)
{
	if(ZDO_SUCCESS_STATUS == conf->status)
	{
		appState = APP_WAIT_STATE;
		sleep = false;	
	}
	
	SYS_PostTask(APL_TASK_ID);
} 


//**********************************************************************************
//  sleepTimerConf()  - 3 seconds
//**********************************************************************************
static void sleepTimerConf()
{
	appState = APP_SLEEP_STATE;
	SYS_PostTask(APL_TASK_ID);
}

//***********************************************************************************
//  ZDO_EndDeviceSleepConf()
//***********************************************************************************
static void ZDO_EndDeviceSleepConf(ZDO_SleepConf_t *conf)
{
	if(sleep_conf_error != ZDO_SUCCESS_STATUS)
	{
		appState = APP_SLEEP_STATE:
		SYS_PostTask(APL_TASK_ID);
	}
	else
	{
		sleep = true;
	}	
}

//***********************************************************************************
//  ZDO_WakeUpInd()
//***********************************************************************************
void ZDO_WakeUpInd(void)
{
	sleep = false;
	appState = APP_WAIT_STATE;
	SYS_PostTask(APL_TASK_ID);
}  

I don't receive any errors form notification functions.

Anyone had similar problem?

Thanks in advance !

Last Edited: Fri. Oct 16, 2015 - 02:17 PM