Re: HW Timer in 2073x (con't)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

Regarding this closed thread here: HW Timer in 2073x

can you explain a little bit that how can we access the register of a timer? I want to start a timer at a specific point and if sth happens later I want to stop the timer and measure the time it took between these two(start and stop). also, this elapsed time is in order of 1-3 milliseconds so the timer resolution must be high I guess. I was thinking of using hw_timer but I didn't find enough resources about its register and how to operate it. if you help me a little I will be thankful forever...(if you have another method of measuring the time between two incidents I  will be thankful to hear it.)

BTW, I'm new to all these and I'm using bcm20737(now cyw20737?)

0 Likes
1 Solution

I think there is some discussion on the stability of the FW operation for anything below 3.5ms as the watchdog may be tripped.

ble_trace0 is to display the argument message when triggered, useful for tracing. There are some good threads in the forum like the below:

BCM20737S HW timer problem

View solution in original post

6 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

You can try out something similar to the below:

devlpm_registerForLowPowerQueries(app_hw_timer_device_lpm_queriable, 0); /*disable sleep*/

hw_timer_register_timer_expired_callback(app_hw_timer_interrupt_handler);

hw_timer_start(100000); /*start the timer, expiring in 100ms*/

void app_hw_timer_int_handler(void)

{

hw_timer_stop(); /*clears interrupt*/

ble_trace0("hw timer fire");

hw_timer_start(100000); /*restart the HW timer to expire in 100ms*/

}

Remember to declare interrupt handler.

Anonymous
Not applicable

Thanks for the answer, I do appreciate it.

from what I understood, this code sets the timer to 100ms but as I said in my previous post, I want to measure time with .5ms accuracy. from what I know of timers, it's a register that has 32 bits so whenever we set it, it will count from 0 to maximum 2^32-1. so here what I want to do, when a specific line execute in my code, I will set a timer and about 1 to 3 milliseconds later when another line of code happens, I want to stop the timer and measure the time between(perhaps by knowing how much it has counted till that moment). As I said the order of this elapsed time is 1 to 3 milliseconds and I want to be able to measure it with at least .5 millisecond accuracy.

about your code, what does ble_trace0("hw timer fire") do? how can I declare interrupt handler? and how can I know how much the timer has counted when I stop the timer?

any help is highly appreciated.

0 Likes

I think there is some discussion on the stability of the FW operation for anything below 3.5ms as the watchdog may be tripped.

ble_trace0 is to display the argument message when triggered, useful for tracing. There are some good threads in the forum like the below:

BCM20737S HW timer problem

Anonymous
Not applicable

Thanks. I could run the hw_timer and solve a part of the problem. I now need to use two timers simultaneously. is there another timer(instead of the fine timer and hw_timer)? if yes, how can I run that? I've heard about something like bleapptimer, but I don't know if that's the same thing as the fine timer and I don't know how to run that.

0 Likes
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hi,

Are you asking about bleapptimer_startTimer in bleapptimer.h ?

-Thanks,
Anjana

0 Likes

You may consider using the SW/app timers:

bleprofile_regTimerCb(app_finetimer_callback, app_timer_callback);

bleprofile_StartTimer();

The app_timer is 1s resolution and the app_finetimer is 12.5ms

Check out any app for the full implementation.