HI ,
My environment:
- nrf connect sdk
- nrf5340 dk
- segger studio ide.
could you please provide me timer example code for nrf5340 board.
Thanks & Regards,
Srinivas.
HI ,
My environment:
could you please provide me timer example code for nrf5340 board.
Thanks & Regards,
Srinivas.
Take a look at the NCS tutorial, section 3.5 Add the ADC peripheral, which provides a sample using a timer. It may be useful to complete 3.2 Set it up, 3.3 Build and flash it and 3.4 Modify the device tree first.
Hi Simon,
Thanks for your reply.
It seems to be zephyr based kernel timers API (soft timers) in the ADC code. can I get hardware based timer example code?
Thanks & Regards,
Srinivas.
RTC peripheral
The k_timer_start() will actually use the RTC peripheral, in the following manner:
By default CONFIG_NRF_RTC_TIMER will be equal to y (check <sample>/build/zephyr/.config), which will make it use the RTC. I think you can use a systick timer by enabling CONFIG_CORTEX_M_SYSTICK. However, RTC is probably the best choice between these: https://devzone.nordicsemi.com/f/nordic-q-a/21067/nrf52-use-systick-or-rtc/82317#82317.
Timer peripheral
The counter.h API enables you to use both the TIMER peripheral as well as the RTC peripheral, by setting CONFIG_COUNTER_NRF_TIMER or CONFIG_COUNTER_NRF_RTC in the prj.conf.
Check out the sample zephyr/samples/drivers/counter/alarm to see how to use the counter API.
If you're wondering if you should use the TIMER or the RTC, I would recommend you to read the following: https://devzone.nordicsemi.com/f/nordic-q-a/12731/clocks-timers-rtc-why/48338#48338. It was written a long time ago for a different chip and SDK, but should be somewhat relevant still
Best regards,
Simon
RTC peripheral
The k_timer_start() will actually use the RTC peripheral, in the following manner:
By default CONFIG_NRF_RTC_TIMER will be equal to y (check <sample>/build/zephyr/.config), which will make it use the RTC. I think you can use a systick timer by enabling CONFIG_CORTEX_M_SYSTICK. However, RTC is probably the best choice between these: https://devzone.nordicsemi.com/f/nordic-q-a/21067/nrf52-use-systick-or-rtc/82317#82317.
Timer peripheral
The counter.h API enables you to use both the TIMER peripheral as well as the RTC peripheral, by setting CONFIG_COUNTER_NRF_TIMER or CONFIG_COUNTER_NRF_RTC in the prj.conf.
Check out the sample zephyr/samples/drivers/counter/alarm to see how to use the counter API.
If you're wondering if you should use the TIMER or the RTC, I would recommend you to read the following: https://devzone.nordicsemi.com/f/nordic-q-a/12731/clocks-timers-rtc-why/48338#48338. It was written a long time ago for a different chip and SDK, but should be somewhat relevant still
Best regards,
Simon