This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

After add app_timer, the system can't work

Hello, I used nRF5_SDK_12.1.0_0d23e2a, SoftDevice 8_9_0, the ble_app_uart_c example code.

I want to add the timer, after add the following code, my system can't work.

#define DELAY_INTERVAL          APP_TIMER_TICKS(1, APP_TIMER_PRESCALER)
static  app_timer_id_t              m_delay_timer_id;
volatile uint16_t                       timer_action_counter = 0;

static void delay_timerout_handler(void * p_context)    
{		
    UNUSED_PARAMETER(p_context);
		
    timer_action_counter++;
    if(!(timer_action_counter%1000))
    {
	printf("Work\r\n");
        timer_action_counter = 0;
    }	
}

static void Timer_Init(void)
{
    uint32_t err_code;
    
    //APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    err_code = app_timer_create(&m_delay_timer_id, APP_TIMER_MODE_REPEATED, delay_timerout_handler);
    
    APP_ERROR_CHECK(err_code);  
}

static void Timer_Start(void)
{	
    uint32_t err_code;
    err_code = app_timer_start(m_delay_timer_id, DELAY_INTERVAL, NULL);	
    
    APP_ERROR_CHECK(err_code);  
}

Please help me, Thanks!

Parents Reply
  • Hello, The ble_app_uart_c example code is already called this function, so i commented out it. And i define APP_TIMER_OP_QUEUE_SIZE is 4.

    int main(void) {

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    
    uart_init();
    Timer_Init();
    buttons_leds_init();
    db_discovery_init();
    ble_stack_init();
    nus_c_init();
    
    printf("Uart_c Scan started!\r\n");
    scan_start();
    
    Timer_Start();
    
    while(1)
    {  
        power_manage();
    }
    

    }

Children
No Data
Related