Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

APP_TIMER do not working

Hi. I'm trying to study nrf52832

but, APP_TIMER do not work.. what should i do?

(1) 

mcu : nrf52832

sdk: nRF5_SDK_15.2.0_9412b96

(2) setting : 

> sdk_config.h -> #define APP_TIMER_ENABLED 1

> set timeout intervals

#define TIMEOUT_INTERVAL_SYSTEM_TIMER APP_TIMER_TICKS(100) // ms
#define TIMEOUT_INTERVAL_LED_TIMER APP_TIMER_TICKS(100) // ms
#define TIMEOUT_INTERVAL_BUTTON_TIMER APP_TIMER_TICKS(100) // ms

(3) flow :

APP_TIMER_DEF(htim1); // System Timer (traffic & sensing)
APP_TIMER_DEF(htim2); // LED Timer
APP_TIMER_DEF(htim3); // Button Timer

void INIT_APP_TIMER(void)
{
err_code = app_timer_init();
err_code |= app_timer_create(&htim1,APP_TIMER_MODE_REPEATED,SystemTimer_timeout_handler);
err_code |= app_timer_create(&htim2,APP_TIMER_MODE_REPEATED,LedTimer_timeout_handler);
err_code |= app_timer_create(&htim3,APP_TIMER_MODE_SINGLE_SHOT,ButtonTimer_timeout_handler);

}

void START_APP_TIMER(void)
{
err_code = app_timer_start(htim1, TIMEOUT_INTERVAL_SYSTEM_TIMER, NULL);
err_code |= app_timer_start(htim2, TIMEOUT_INTERVAL_LED_TIMER, NULL);
err_code |= app_timer_start(htim3, TIMEOUT_INTERVAL_BUTTON_TIMER, NULL);
}

int main(void)
{
INIT_APP_TIMER();

START_APP_TIMER();

while (true){}

}

(4) timeout handlers :

uint32_t count1=0,count2=0,count3=0;
void SystemTimer_timeout_handler(void * p_context)
{
count1++;
}

void LedTimer_timeout_handler(void * p_context)
{
count2++;
}

void ButtonTimer_timeout_handler(void * p_context)
{
count3++;
}

Parents Reply Children
Related