I am new in the nRF52832 controller so help me for coding of my question. any help will be appreciated. thank you.
I am new in the nRF52832 controller so help me for coding of my question. any help will be appreciated. thank you.
Havent tested this, but it should work
#include "app_timer.h"
#include "app_error.h"
#define TICKS_7_SECONDS APP_TIMER_TICKS(7000)
APP_TIMER_DEF(my_timer);
static void my_timer_timeout_handler(void * p_context)
{
// 7 seconds passed.
// Do something
}
int main(void)
{
uint32_t err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
err_code = app_timer_create(&my_timer, APP_TIMER_MODE_SINGLE_SHOT, my_timer_timeout_handler);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(my_timer, TICKS_7_SECONDS, NULL);
APP_ERROR_CHECK(err_code);
for(;;)
{
// Busy waiting
}
return 0;
}
Havent tested this, but it should work
#include "app_timer.h"
#include "app_error.h"
#define TICKS_7_SECONDS APP_TIMER_TICKS(7000)
APP_TIMER_DEF(my_timer);
static void my_timer_timeout_handler(void * p_context)
{
// 7 seconds passed.
// Do something
}
int main(void)
{
uint32_t err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
err_code = app_timer_create(&my_timer, APP_TIMER_MODE_SINGLE_SHOT, my_timer_timeout_handler);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(my_timer, TICKS_7_SECONDS, NULL);
APP_ERROR_CHECK(err_code);
for(;;)
{
// Busy waiting
}
return 0;
}
Check the example located here: nRF5_SDK_13.0.0_04a0bfd\examples\peripheral\timer It does what you want.
hi, shibshab ! I have done this only using application timer, not timer so you can help me.means I can control the timer globally for led controlling (ex: 1s,2s etc). so you can plz help me with the coding. because I am new so problem facing during implement the timer in code so I need help.
If you mean you need to use a TIMER module, you could have a look at this example on Github.
It was written for the nRF51, but the TIMER modules in the nRF52 are identical.
Best regards