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

err_code = 0x07 after calling a timer start

Hi, I got an err_code = 0x00000007 after calling this function.

void system_timer_start(void)
{
	uint32_t err_code;

	
	err_code = app_timer_start(m_one_ms_timer_id, ONE_MILLISEC_TICKS, NULL);

	if(err_code != NRF_SUCCESS)
	{
		
	}

	APP_ERROR_CHECK(err_code);
}

m_one_ms_timer_id has been correctly initialized through this function

err_code = app_timer_create(&m_one_ms_timer_id,
		APP_TIMER_MODE_REPEATED,
		one_ms_timeout_handler);
APP_ERROR_CHECK(err_code);

Here, err_code is = 0x00. So, what is the invalid parameter in system_timer_start()? I use sd 130 and nrf51822.

Parents
  • I discovered the problem

    uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context)
    {
        uint32_t timeout_periodic;
        timer_node_t * p_node = (timer_node_t*)timer_id;
        
        // Check state and parameters
        VERIFY_MODULE_INITIALIZED();
    
        if (timer_id == 0)
        {
            return NRF_ERROR_INVALID_STATE;
        }
        if (timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS)
        {
            return NRF_ERROR_INVALID_PARAM;
        }
        if (p_node->p_timeout_handler == NULL)
        {
            return NRF_ERROR_INVALID_STATE;
        }
        
        // Schedule timer start operation
        timeout_periodic = (p_node->mode == APP_TIMER_MODE_REPEATED) ? timeout_ticks : 0;
    
        return timer_start_op_schedule(user_id_get(),
                                       p_node,
                                       timeout_ticks,
                                       timeout_periodic,
                                       p_context);
    }
    

    if (timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS) was true because APP_TIMER_MIN_TIMEOUT_TICKS = 60 and ONE_MILLISEC_TICKS = 33. Concerning the 1984, the debugger showed the correct value (60) using optimization 0 ( before I used optimization 3) Why? Thanks for the suggestion!

Reply
  • I discovered the problem

    uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context)
    {
        uint32_t timeout_periodic;
        timer_node_t * p_node = (timer_node_t*)timer_id;
        
        // Check state and parameters
        VERIFY_MODULE_INITIALIZED();
    
        if (timer_id == 0)
        {
            return NRF_ERROR_INVALID_STATE;
        }
        if (timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS)
        {
            return NRF_ERROR_INVALID_PARAM;
        }
        if (p_node->p_timeout_handler == NULL)
        {
            return NRF_ERROR_INVALID_STATE;
        }
        
        // Schedule timer start operation
        timeout_periodic = (p_node->mode == APP_TIMER_MODE_REPEATED) ? timeout_ticks : 0;
    
        return timer_start_op_schedule(user_id_get(),
                                       p_node,
                                       timeout_ticks,
                                       timeout_periodic,
                                       p_context);
    }
    

    if (timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS) was true because APP_TIMER_MIN_TIMEOUT_TICKS = 60 and ONE_MILLISEC_TICKS = 33. Concerning the 1984, the debugger showed the correct value (60) using optimization 0 ( before I used optimization 3) Why? Thanks for the suggestion!

Children
No Data
Related