This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ble_app_template & app_timer

Hi, I'm working with the nRF51822 I'm trying to enable the use of some timer callback on the ble_app_template. I've succefully created and started all the timers, but i've no callback response. I suppose I'm making some mistakes in timer initialization procedure.

#define APP_TIMER_PRESCALER             0                                           /**< Value of the RTC1 PRESCALER register. */
#define APP_TIMER_MAX_TIMERS            (2 + BSP_APP_TIMERS_NUMBER)                 /**< Maximum number of simultaneously created timers. */
#define APP_TIMER_OP_QUEUE_SIZE         4                                           /**< Size of timer operation queues. */
static app_timer_id_t  m_app_timer_id;
static app_timer_id_t  m_battery_timer_id;
#define TIMER_INTERVAL 	APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER)   /**< LED Softblink PWM period in app_timer ticks. */

static void timers_init(void)
{
    uint32_t err_code;
	// Initialize timer module, making it use the scheduler
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);

    /* YOUR_JOB: Create any timers to be used by the application.
                 Below is an example of how to create a timer.
                 For every new timer needed, increase the value of the macro APP_TIMER_MAX_TIMERS by
                 one.
	*/
    err_code = app_timer_create(&m_app_timer_id, APP_TIMER_MODE_REPEATED, timer_timeout_handler);
    APP_ERROR_CHECK(err_code); 
	
	err_code = app_timer_create(&m_battery_timer_id, APP_TIMER_MODE_REPEATED, battery_level_meas_timeout_handler);
	APP_ERROR_CHECK(err_code);
}

static void timers_start(void)
{
    /*YOUR_JOB: Start your timers. below is an example of how to start a timer. */
    uint32_t err_code;

    err_code = app_timer_start(m_app_timer_id, TIMER_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);

    err_code = app_timer_start(m_battery_timer_id, TIMER_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);	
}

int main(void)
{

    // Initialize
    timers_init();
    // Start execution
    timers_start();



for(;;)
{
        power_manage();
}
}

I report only the code related to the timer initialization and run. If I put a breakpoint in timer_timeout_handler() i never get the PC to stop on it.

BR.

Parents
  • I just used your code to hook up my timers. My init is different than yours and maybe helpful

    void timer_init(void)
    

    {

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    
    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    
    app_timer_create(&shock_strength_button_press_timer, APP_TIMER_MODE_REPEATED, buttonPressTimeout);   	
    

    }

    void buttonPressTimeout(void * p_context) { #ifdef LOG_ME APPL_LOG("[APPL]: BUTTON PRESS TIMEOUT\r\n"); #endif

    }

    //T0 Start timer

    uint32_t err_code;

    err_code = app_timer_start(shock_strength_button_press_timer, TIMER_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);
    
  • Dear Charles,

    Thanks fo your suggestion, but it didn't work for me. After some debugging I've found that the initialization of the SofDevice handler module, disable the SWI0_IRQ. In my app I call the timers_init before that, so the SWI0_IRQ was not served!

    BR.

Reply Children
No Data
Related