Timer stops after a while

9 posts / 0 new
Last post
Cusko
Offline
Last seen:3 years 1 month ago
加入:2014-09-24 14:43
Timer stops after a while

I use a timer to send BT notification to my Windows application. But after same time the timer stops working. The timer starts when connection occurs with ke_timer_set(APP_SAMPLE128_TIMER, TASK_APP, 50); It works for a while then it stops when it shouldn't. Different time period every time. I debug with Keil uvision. When timer stop functioning I press stop and the program pointer is on GLOBAL_INT_START(). When I click continue the timer starts working again.
When the timer stops working I can still write to a profile characteristic, so the program is not halted completely.
Here is my timer handler function:

int sample128_timer_handler(ke_msg_id_t const msgid, struct gapm_cmp_evt const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) {
float tmp;
static uint8_t toggle=1;
tmp = Pressure_read(SENSOR_1);
Led_Green(toggle);
toggle^=1;
struct sample128_upd_char2_req *要求= KE_MSG_ALLOC( SAMPLE128_UPD_CHAR2_REQ, TASK_SAMPLE128, TASK_APP, sample128_upd_char2_req);
memcpy(&req->val, &tmp, sizeof(float));
req->conhdl = app_env.conhdl;
ke_msg_send(req);
ke_timer_set(APP_SAMPLE128_TIMER, TASK_APP, 20);
return (KE_MSG_CONSUMED);
}

Device:
MT_dialog
Offline
Last seen:4 weeks 3 hours ago
工作人员
加入:2015-06-08 11:34
Hi Cusko,

Hi Cusko,

Can you please try to check if this incident occurs when there is no reading of the sensor? can you just increment the values that you are sending. Also can you please check if the incident occurs when you are connected to an android device ? Is there anywhere anything in your code that cancels the timer (invoke ke_timer_clear()) perhaps it passes througn this function somehow. Ive tested with sending a float value incremented by a fixed value i didn't see any issues regarding the timer not executed.

Thanks MT_dialog

Cusko
Offline
Last seen:3 years 1 month ago
加入:2014-09-24 14:43
I commented the sensor

I commented the sensor reading and the incident still occurs. I added second timer just to toggle another led light, no BT stuff. When the first timer stops, the second timer stops also. I stop the first timer (where I increment and send notification) in disconnection function and start it when device is connected. The blinking timer starts in app_set_dev_config_complete_func() and I never stop it. So when the both timers broke at the same time I press stop and then continue. The first timer starts working again (because the disconnection and connection routine), but the second blink timer never starts again.
I don't have android device to test this yet.

Cusko
Offline
Last seen:3 years 1 month ago
加入:2014-09-24 14:43
And I did another thing. I

And I did another thing. I remove all BT stuff from the first timer and the problem still remains. The device is connected but the timers don't work anymore.

MT_dialog
Offline
Last seen:4 weeks 3 hours ago
工作人员
加入:2015-06-08 11:34
Hi Cusko,

Hi Cusko,

In the documents section of the 580 in the applications notes section there is a .zip file that includes some examples for the creation of the custom profile. The project sample128_After section 7.2 is an example that implements one single timer to send notifications over BLE. On an android phone i dont see any issues regarding the timer, and the notifications are properly received. I suppose that your implementation is similar (just activate timer upon connection and send a notification in every timeout of the timer), can you please give it a try with that example ?

Thanks MT_dialog

Cusko
Offline
Last seen:3 years 1 month ago
加入:2014-09-24 14:43
The sample128_After section 7

The sample128_After section 7.2 works ok. But what would stop timers to work in my case?

MT_dialog
Offline
Last seen:4 weeks 3 hours ago
工作人员
加入:2015-06-08 11:34
Hi Cusko,

Hi Cusko,

Do you clear the timers anywhere in your code, or reset the timer before the ble is awake ? These are the only reasons i can think of that a timer doesn't elapses. Since you have a working project you can compare and find the difference between the demo and your code.

Thanks MT_dialog

Cusko
Offline
Last seen:3 years 1 month ago
加入:2014-09-24 14:43
No I don't clear the timers

No I don't clear the timers and I reset the timer only in handler function. Maybe some uart problem or something. I will compare and report.

Cusko
Offline
Last seen:3 years 1 month ago
加入:2014-09-24 14:43
It was something wrong in

It was something wrong in periph_init() function. I change the register settings like in the sample128_After section 7.2 and now the timers work OK and don't stop after a while. Thanks for help.

Topic locked