I have a problem ,ke_time is not succeed execute everytime.
in detail:
In SDK 3.0.6,I used a button P23 to power on the system.
void app_button_enable(void)
{
wkupct_register_callback(app_button_press_cb);
//if (!(GPIO_GetPinStatus( GPIO_BUTTON_PORT, GPIO_BUTTON_PIN )) ) //button is p23
wkupct_enable_irq(0x80000, 0, 1, 10); // P2_3, polarity low , 1 0x40000
}
in app_button_press_cb(void)
I add this:
havekey_flag =1;
如果(keytimescn > = 1)
{
keytimescn =0;
ke_timer_clear(SCAN_KEY_TIMER,TASK_APP);
}
keytimescn++;
if(PW_ON_OFF!=0) //power off statue to power on
{
//ke_timer_init();
GPIO_SetInactive(GPIO_TI_LED_PORT,GPIO_TI_LED_PIN); //fot tip enter here the led is on
ke_timer_set(SOTF_PW_TIMER,TASK_APP,200); //only here call SOTF_PW_TIMER's function
// app_force_active_mode();
}
else
{ //search for 400MS_key
GPIO_SetInactive ( GPIO_ALERT_LED_PORT, GPIO_ALERT_LED_PIN); //fot tip enter here the led is on
button_type =BUTTONTYPE_400MS;
ke_timer_set(SCAN_KEY_TIMER,TASK_APP,40);
// app_force_active_mode();
}
here I haved add MSG
enum APP_MSG
{
APP_MODULE_INIT_CMP_EVT = KE_FIRST_MSG(TASK_APP),
SOTF_PW_TIMER,
............
............
}
/* Default State handlers definition. */
EXTERN const struct ke_msg_handler app_default_state[] =
{
{SOTF_PW_TIMER, (ke_msg_func_t)poweron_soft_handler},
{GAPM_DEVICE_READY_IND, (ke_msg_func_t)gapm_device_ready_ind_handler},
.............
...........
}
In handler function:
int poweron_soft_handler(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
GPIO_SetInactive( GPIO_ALERT_LED_PORT, GPIO_ALERT_LED_PIN); //fot tip enter here. the led is on
{//soft poweron is the first prio
PW_ON_OFF =0;
been_tip_flag =0;
app_adv_start();
led_been_loop =TIP_LOOP_LEDON;
ke_timer_set(LEN_BEEN_TIP_TIMER,TASK_APP,1);
}
ke_timer_clear(SOTF_PW_TIMER,TASK_APP);
return (KE_MSG_CONSUMED);
}
I press key P23 to high one time last 6s { greater than in set here (ke_timer_set(SOTF_PW_TIMER,TASK_APP,200) 2s};
have enter the step:
GPIO_SetInactive(GPIO_TI_LED_PORT,GPIO_TI_LED_PIN); //fot tip enter here the led is on
但有时the step is not in:
GPIO_SetInactive( GPIO_ALERT_LED_PORT, GPIO_ALERT_LED_PIN); //fot tip enter here. the led is on
so the system is not poweron everytime.
my question is :
ke_timer_set(SOTF_PW_TIMER,TASK_APP,200); //only here call SOTF_PW_TIMER's function
但有时this function
poweron_soft_handler
is not call succeed.
why?
additional:
I have view this
http://support.dialog-semiconductor.com/faq/how-use-ketimer-during-wakeu...
but in 3.0.6 have no this MSG
struct create_new_timer_struct *req = KE_MSG_ALLOC(APP_CREATE_NEW_TIMER, TASK_APP, TASK_APP,
create_new_timer_struct);
create_new_timer_struct
and
APP_CREATE_NEW_TIMER
not included in my used SDK(3.0.6).
You may do following these steps:
{
uint16_t delay;
uint16_t task_id;
uint16_t timer_id;
};
in app.h
Hope it helps.
Or sometimes enter KE_timer task function is delay more than 15 second;
Or KE_timer task function is not action at all.
please give me you help.
very thank you .
Hi YuanhangWu
The most probable reason that your device isn't working is the fact that you are trying to set up an ke_timer while the device hasn't been woken up yet. When you are waking up your device through the wakeup timer nobody guaranties that the BLE Core is awake and the software timers are part of the BLE Core. Even if you force your BLE to wake up it is uncertain if the timer is going to be set up properly because it takes some time for the core to wake up. As a work around what you can try is to check first if your BLE is active by using the app_check_BLE_active() function and then set up your timer as it is describedhttp://support.dialog-semiconductor.com/faq/how-use-ketimer-during-wakeu...here. You can add the struct and the message as it is being described by summer20100514. That way you will send a message to the application about the creation of a timer and you know for sure that when you call the ke_timer_set the BLE will be awaken.
Thanks MT_dialog
thanks MT_dialog,
thanks summer20100514.
Before every ke_timer_set() function,I add this
如果(app_ble_force_wakeup ())
app_ble_ext_wakeup_off();
There were no problems found at present.
So handler by this way ,What risks hide?
Hi YuanhangWu,
We cant be sure about the side effects this will cause, the work around for the problem is the one described above. What could happen is that even if the app_ble_force_wakeup() is executed and the BLE starts the waking up it takes time until the BLE wakes up this may result in the same problems you had before. The reason of the workaround is to make sure that the BLE is certainly awake when the ke_timer_set() is invoked, thats why at first send a message to the kernel to set the ke_timer.
Thanks MT_dialog
thank you MT_dialog,summer20100514.
I used ke_timer_set() as you give suggestion before;
When key press,I 100ms interval to read the GPIO pin.
If is also pressed,then keytimescn++;
so i call ke_timer_set() in ke_timer_func;call back several times.
but the test result is follow:
sometimes ,also not run very accurate everytime;sometimes , ke_timer_set() is not run;
So i used systick to solve it.
but it is not work in sleep,so,when is press,i wake up until press is realse.
So handler by this way ,What risks hide?
Hi YuanhangWu,
If my undestanding is correct, you are holding the da in the Wakeup Handler until your button is released, in the wake up handler you are setting the systick and start your counting. The only thing i can think of is that you should make sure that your clocks are propely setted so the systick is properly feeded. If not your timing is going to be inaccurate.
Thanks MT_dialog