ke_timer_set不执行,为什么?

8个帖子/ 0新
Last post
YuanhangWu
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 08:19
ke_timer_set不执行,为什么?

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;

if(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
{//搜索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();
}

在这里我有没有添加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};
已输入步骤:
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.

我的问题是:
ke_timer_set(SOTF_PW_TIMER,TASK_APP,200); //only here call SOTF_PW_TIMER's function

但有时this function
poweron_soft_handler

不打电话成功。

why?

额外的:
我有这个看法
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

app_create_new_timer.
not included in my used SDK(3.0.6).

Keywords:
Device:
summer20100514
Offline
Last seen:4年2个月前
格鲁鲁
加入:2014-12-30 05:01
你可以遵守这些

你可以遵守这些steps:

  1. add APP_CREATE_NEW_TIMER in app_api.h
  2. add {APP_CREATE_NEW_TIMER, (ke_msg_func_t)app_create_new_timer} in app_task_handlers.h
  3. 添加struct create_new_timer_struct.
    {
    uint16_t delay;
    uint16_t task_id;
    uint16_t timer_id;
    };
    in app.h

Hope it helps.

YuanhangWu
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 08:19
或者有时输入ke_timer

或者有时输入ke_timertask 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 .

MT_dialog
Offline
Last seen:1 week 1 day ago
Staff
加入:2015-06-08 11:34
Hi YuanhangWu

Hi YuanhangWu

您的设备无法正常工作的最可能原因是您尝试在设备尚未唤醒时设置Ke_Timer。当您通过唤醒定时器唤醒您的设备时,无人保证BLE核心是清醒的,软件定时器是BLE核心的一部分。即使你迫使你的ble醒来,它是不确定的,如果定时器将被正确设置,因为核心需要一些时间醒来。作为在您可以尝试的过程中,如果使用app_check_ble_active()函数,则首先检查首先,然后按照描述设置计时器http://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

YuanhangWu
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 08:19
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?

MT_dialog
Offline
Last seen:1 week 1 day ago
Staff
加入:2015-06-08 11:34
Hi YuanhangWu,

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

YuanhangWu
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 08:19
thank you 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:
有时,也没有每次运行非常准确;有时,ke_timer_set()未运行;

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?

MT_dialog
Offline
Last seen:1 week 1 day ago
Staff
加入:2015-06-08 11:34
Hi YuanhangWu,

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