17 posts / 0 new
Last post
Kim
Offline
Last seen:7 years 3 months ago
加入:2014-03-14 14:55
app_timer_set

Hi,

In the sample code, I have seen this function and I'm thinking when calling it, it will execute it's assigned function after a delay. I have traced back how to do this by looking at the proximity reporter example code, but I couldn't get it working.
Is there a document where I can find more information? (I've looked through them, but couldn't find anything)

Thanks,
Kim

JE_Dialog
Offline
Last seen:3 months 5 days ago
工作人员
加入:2013-12-05 14:02
Hell Kim, I have asked the SW

Hell Kim, I have asked the SW team for some feedback and will respond to your quesion as soon as i have an answer on the description of app_timer_set function. Its not detailed in the SW documentation that is online right now..
BR JE_Dialog

Johannes.steensma
Offline
Last seen:3 months 5 days ago
加入:2014-04-29 16:38
Kim,

Kim,

The app_timer_set is not executing a delayed function, but rather sends a delayed message. You mus therefore registera handler for this message.

To get the timer working:
1) add handler in app_task_handlers.h in the app_default_state.

{APP_MY_TIMER, (ke_msg_func_t)app_my_timer_handler},

2) Implement the Handler

int app_my_timer_handler(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
/** Do your delayed function here */
return (KE_MSG_CONSUMED);
}

3) Call the app_timer_set

ke_timer_set(APP_MY_TIMER, TASK_APP, 100); // 100 is 1 sec

Note that the app_timer_set has a 10 ms accuracy.

Johannes

AK_Dialog
Offline
Last seen:1 week 4 days ago
工作人员
加入:2013-12-16 15:49
Hi Kim,

Hi Kim,
More info about this timer can be found in the following documentation (on this website):
RW-BLE Kernel Functional Specification, starting at page 14.
Best regards,

Dialog Bluetooth Support Team

ejong69
Offline
Last seen:2 years 4 months ago
加入:2014-06-23 07:11
Hi,

Hi,
In RW-BLE Kernel Functional Specification 1.1, Chapter 7.5.1, the description say,

void ke_timer_set(ke_msg_id_t const timer_id, ke_task_id_t const task, uint16_t const delay);
The function first cancel the timer if it exists, then it creates a new one. The timer can be one-shot or periodic, i.e. it
will be automatically set again after each trigger.

I didn't figure out how to configure the timer either one-shot or periodec. I don't see any paremeter for one-shot or periodic with ke_timer_set.
Could you please let me know?
Thank you.
--
Jason Lee

RandyYu
Offline
Last seen:3 years 2 months ago
加入:2015-01-28 08:49
I am not search the file RW

I am not search the file RW-BLE Kernel Functional Specification,canyou give me a URL?

MT_dialog
Offline
Last seen:6 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi RandyYu,

Hi RandyYu,

你可以找到的文档资料和APIcuments section in the Documents tab on the support site, here is the linkhttp://support.dialog-semiconductor.com/resource/rw-ble-kernel-functiona....

Thanks MT_dialog

Joacimwe
Offline
Last seen:1 year 9 months ago
Guru
加入:2014-01-14 06:45
作为far as I know, the timer

作为far as I know, the timer documentation is pretty broken in many places:
- There is no parameter for setting the timer to one-shot or periodic.
- Description of ke_timer_active is wrong: "This function pops the first timer from the timer queue and notifies the appropriate task by sending a kernel message.
If the timer is periodic, it is set again; if it is one-shot, the timer is freed. The function checks also the next timers and
process them if they have expired or are about to expire.". It doesn't do that at all. It simply checks if the timer is active and nothing else.
- Description of ke_timer_clear is wrong: "This function searches for the timer element identifed by its timer and task identifers. If found, it is stopped and
freed, otherwise an error message is returned.". The function returns void, so it does NOT return an error message if the timer is not found. (You can simply use ke_timer_active to see if it doesn't exist).

A very important note: Once the timer has timedout and been fired, a message is put in the end of the message queue and the timer is removed. This means if you run ke_timer_active while the message is in the message queue and not yet been handled, it will return false, and if you run ke_timer_clear, nothing will happen, and if you run ke_timer_set, a new timer will start which means you later will first receive the first message, and after the timer has trigged, you will get the next message.

So, if you simply want a periodic timer: start it once and in the end of the timer message handler, just start a new timer.

sklin
Offline
Last seen:6 years 2 months ago
Expert
加入:2014-08-12 08:01
Hi Joacimwe

Hi Joacimwe
I have make a timer,and it's stopped automatically when it has generated a timer message.
If I don't start again,it will not trigger again.It seems that it is a one-shot timer.
But you said that "if you run ke_timer_clear, nothing will happen".
Now,If I start a timer,and I want to stop it before trigger a message,how to do it.

ejong69
Offline
Last seen:2 years 4 months ago
加入:2014-06-23 07:11
It's clear. Thank you.

It's clear. Thank you.

Joacimwe
Offline
Last seen:1 year 9 months ago
Guru
加入:2014-01-14 06:45
We use the clear function but

We use the clear function but also a global flag variable to check if it should run or not, since the clear function is not enough.

Matthieu ANTOINE
Offline
Last seen:4 years 9 months ago
Expert
加入:2014-01-14 14:51
Hi all,

Hi all,

Some people here seem to master the timer. So I need some help from you.

I try to implement a timer to make a LED blink when the device is connected. I followed your explanations but i am facing an issue that I do not understand: the timer works when extended/deep sleep mode is not enabled but when I activate extended, the LED go mad.

Is there anything I need to know about that? In the proximity example, LED is managed that way and it works...

Thanks in advance !

ejong69
Offline
Last seen:2 years 4 months ago
加入:2014-06-23 07:11
Hi Matthieu,

Hi Matthieu,
I am still trying to figure out how app_timer_set works exactly at EXTENDED or DEEP sleep mode.
But, I wonder if you also consider below.

uint8_t flag_led __attribute__((section("retention_mem_area0"),zero_init));;
int app_my_timer_handler(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{

app_timer_set(APP_MY_TIMER, TASK_APP, 100); // 1000ms

if (flag_led == 1)
{
flag_led = 0;
GPIO_SetActive( GPIO_BAT_LED_PORT, GPIO_BAT_LED_PIN );
}
else
{
flag_led =1;
GPIO_SetInactive(GPIO_BAT_LED_PORT, GPIO_BAT_LED_PIN);
}
return (KE_MSG_CONSUMED);
}

With above code, when EXTENDED or DEEP, you shouldn't expect 50% duty cycle of LED blinking because peripheral power down and LED will turn off if your LED is powered from Dialog GPIO.

Matthieu ANTOINE
Offline
Last seen:4 years 9 months ago
Expert
加入:2014-01-14 14:51
Hi,

Hi,

Thanks for your help.
I implemented what you recommend but I still have a different behaviour between active mode and extended sleep mode.

Matt

JE_Dialog
Offline
Last seen:3 months 5 days ago
工作人员
加入:2013-12-05 14:02
Hi Matt, one of the team will

Hi Matt, one of the team will give you a call to walk through the issue you are seeing.

BR JE_Dialog

Alex Luo
Offline
Last seen:1 year 7 months ago
Expert
加入:2014-02-28 19:16
Hi JE,

Hi JE,

Could you verify the accuracy of app_timer_set? Johannes said 10ms accuracy for 1sec, how about percentage or for lomger time like 1min?

Thank

yassin.bennaceur
Offline
Last seen:6 years 1 month ago
加入:2015-04-10 15:32
so the smallest unit is 10ms

so the smallest unit is 10ms ?? what is I need to use the timer in micro seconds ?