Hi ,
I want to create a periodic task which has to run every 10 seconds, how can I create such a task?should I use threads for it? And which clock source does the task use to count 10 seconds?
Thank you for your help!
Hi ,
I want to create a periodic task which has to run every 10 seconds, how can I create such a task?should I use threads for it? And which clock source does the task use to count 10 seconds?
Thank you for your help!
Please look at any one of the examples in the SDK, pretty much every single one of which uses app_timer one way or another. app_timer will do repeated tasks for you.
The application timer tutorial might also be of interest, to learn how to use the library. Note that the API have changed slightly in the latest SDK versions. Please refer the timer library documentation.
Thank you Rk for your response! Thank you Jorgen for your answer too, But actually I'm using Mesh SDK and I want to use TIMER1 to create periodic task which runs every 30 seconds, and I also need to do some delays in some other part of my application, which I also think I have to use my TIMER1 as a clock source for delay then I have to create a function that makes delays for me using TIMER1, so my question is am I able to do such a thing without resetting my TIMER1 ?
Why do you want to use TIMER1 for such a long delay? RTC (or app_timer which use RTC as the clock source) is accurate enough for such long delay, and will provide lower power consumption. It is possible to create multiple timers/delays using a single TIMER peripheral as well, but you will have to create some sort of software control if you do not clear the timer when it reaches the compare value. Please have a look at the timer peripheral example in the normal SDK for details on how to use the TIMER peripheral for single periodic timer. Which device and Mesh SDK version are you using?
I'm using NRF52-DK(nRF52832) and Mesh sdk v10.1 Alpha. actually I tried to create a COMPARE_EVENT on TIMER1 but I don't know how to create a interrupt handler for it. cause when I enable interrupt for timer1 the whole program crashes (it complains about the NVIC_EnableIRQ(TIMER1_IRQn)) , can you please help me to find out how can I enable interrupts for TIMER1 or RTC1 in Mesh SDK ? And how should I creat a call back handler for it ?