2 posts / 0 new
Last post
giuseppe
Offline
Last seen:4 years 9 months ago
Expert
加入:2015-03-25 13:34
Wake up problem

Hi to all,
I have a problem during wake up.
This is the code:

void periph_init(void)
{
// Power up peripherals' power domain
SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0);
while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)) ;

SetBits16(CLK_16M_REG,XTAL16_BIAS_SH_DISABLE, 1);

//rom patch
patch_func();

//Init pads
set_pad_functions();
/ /启用垫
SetBits16(SYS_CTRL_REG, PAD_LATCH_EN, 1);

//interrupt on GPIO pin
wkupct_register_callback(app_wkup_handler);
wkupct_enable_irq(0x00000040,1,1,0x3F); //3F=63ms

set_system_timer();
set_pwm_timer();

}
void app_wkup_handler(void){

if(app_env.sleep){
//flag sleep off
app_env.sleep=false;
app_env.cont_sleep=0;

if(GetBits16(SYS_STAT_REG, PER_IS_DOWN))
periph_init();

//restore radio
if (app_ble_ext_wakeup_get()){
SetBits32(GP_CONTROL_REG, BLE_WAKEUP_REQ, 1);
app_ble_ext_wakeup_off();
}

//start advertisement
app_adv_start();

app_timer_set(READ_SENS, TASK_APP, 1);

}
}
int sleep_on_handler(ke_msg_id_t const msgid, const void *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
{
app_env.sleep=true;

if(ke_state_get(TASK_MYAPP)==MYAPP_CONNECTED)
app_disconnect();
else
app_adv_stop();

app_ble_ext_wakeup_on();

return (KE_MSG_CONSUMED);
}

The system does 10 readings from sensor, turn on the LED and call sleep_on_handler that stop advertise or disconnect and turn off the led. If button is pressed app_wkup_handler is called and advertise restart and readings from sensor restart. If the button is pressed after few seconds that the system as shut down, there are never any problems.
If the button is pressed after several minutes or several hours, the system don't start properly:
- start advertising
- led don't turn on
- DA does not accept connections
- DA don't turn off
The problem does not occur always but with a certain frequency, approximately 50% of the time.
What is the problem? I have done something wrong in the wake up procedure or before turn off the device?

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Guiseppe,

Hi Guiseppe,

I can see that in your wake up function you set the kernel timer that polls your sensor. Can you please follow this FAQhttp://support.dialog-semiconductor.com/faq/how-use-ketimer-during-wakeu...maybe this is causing the probelm you are facing. Other than that you have to debug your program in order to check why your device doesn't wake up when you are issuing an interrupt.

Thanks MT_dialog