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

add timer in hid_mouse

I want to add timer to send sensor movement data to PC every 8ms(125HZ).

But when I add app_timer like normal

1.raise APP_TIMER_MAX_TIMERS 2.raise APP_TIMER_OP_QUEUE_SIZE 3. add handler

static void sensor_movement_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
	mouse_sensor_send();
}
  1. create timer in timer_init()
    err_code = app_timer_create(&m_sensor_timer_id,
                                APP_TIMER_MODE_REPEATED,	   
                                sensor_movement_handler);  				                            
    APP_ERROR_CHECK(err_code);

5.start timer

    err_code = app_timer_start(m_sensor_timer_id, SENSOR_MOVE_SEND_TICKS, NULL);
    APP_ERROR_CHECK(err_code);

======= I add timer like this before in the same program,but failed this one It will goes into app_error_handler() ,and reboot auto.

So I want to known that,is there limit in APP_TIMER_INIT ?

#define APP_TIMER_PRESCALER 0 /< Value of the RTC1 PRESCALER register. */ #define APP_TIMER_MAX_TIMERS 6 //5 /< Maximum number of simultaneously created timers. */ #define APP_TIMER_OP_QUEUE_SIZE 5 //4


 APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, true);

And it shows that error comes from "app_timer.c" m_evt_schedule_func, and error_code is "4"

static void timeout_handler_exec(timer_node_t * p_timer)
{
    if (m_evt_schedule_func != NULL)
    {
        uint32_t err_code = m_evt_schedule_func(p_timer->p_timeout_handler, p_timer->p_context);
        APP_ERROR_CHECK(err_code);
    }
    else
    {
        p_timer->p_timeout_handler(p_timer->p_context);
    }
}
Parents
  • How can I count the memory ? In the keil I set 0x2000 memory for softdevice and another for app as default. Can I reduce the memory that softdevice use?

    When I use 4 timer the memory is not enough too when goes into conn_params_init().

    I just comment out some other timer and try #define APP_TIMER_MAX_TIMERS 2 //5 /< Maximum number of simultaneously created timers. */ #define APP_TIMER_OP_QUEUE_SIZE 2 //4 /< Size of timer operation queues. */

    Error code of “4” is still there. But I was success to add 4 timer in this program. Is there very different between timer of APP_TIMER_MODE_REPEATED and APP_TIMER_MODE_SINGLE_SHOT in memory?

  • the app timer module uses static memory allocation. Set APP_TIMER_MAX_TIMERS to a higher number (6 or higher in your case.)

    -Håkon

Reply Children
No Data
Related