Hi,
Could you please help me how to configure Timer-0/1/2 in timer mode with periodic interval.
With regards,
Praveen P
Hi,
Could you please help me how to configure Timer-0/1/2 in timer mode with periodic interval.
With regards,
Praveen P
Hi.
First, you might also want to take a look at Zephyr's timer API, even though these are software timers: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/kernel/timing/timers.html
Other than that, I do not know about any other Zephyr API that access to timers. However, you can still use the nrfx drivers from the nRF5 SDK.
You can find the available API in <NCS>/modules/hal/nordic/nrfx/drivers/include/nrfx_timer.h.
Attached is a quick sample application that sets up an interrupt to happen every second.
Best regards,
Didrik
Hi Didrik,
Thank you for sharing me sample code.
regards,
Praveen
Hi Didrik,
Thank you for sharing me sample code.
regards,
Praveen
How can I create a timer, with the timeout is 5mn, after 5mn, it will enable GPS - THINGY:91?
In your code, I changed the TIMEOUT = 300000 // 5mn, but the interrupt always happened every second.
Thanks,
Hoang
Hi Hoang.
The counter only has 16 bits, so it is not able to count up to 300000 * ticks/ms.
However, I am not sure if I would use a timer for that in the first place. Instead, I would take a look delayed work items: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.2.0/zephyr/reference/kernel/threads/workqueue.html#delayed-work
Best regards,
Didrik
Dear Didrik Rokhaug,
the counter 16bits, xFFFF = 65 535 max value and with the
my_timer_config.frequency = NRF_TIMER_FREQ_31250Hz;
--> T = 32us
16bits counter can count to 65535 x32us = 2,09712 s, is it correct?
I checked on the document:
void nrfx_timer_compare | ( | nrfx_timer_t const *const | p_instance, |
nrf_timer_cc_channel_t | cc_channel, | ||
uint32_t | cc_value, | ||
bool | enable_int | ||
) |
cc_value is the ticks/ms, is it right ? how can we calculate this value from the TIMEOUT (as nrfx_timer_ms_to_ticks(&my_timer, TIMEOUT);)
Thanks so much
Regards,
Hoang Nguyen
Hoang said:16bits counter can count to 65535 x32us = 2,09712 s, is it correct?
Yes, that is correct.
cc_value is the number of ticks you count up to. You can get this value by multiplying the TIMEOUT with the frequency (assuming you are working with s and Hz as units, if not apply correct scaling).
You can find the calculations done in nrfx_timer_ms_to_ticks here: https://github.com/zephyrproject-rtos/hal_nordic/blob/master/nrfx/hal/nrf_timer.h#L715