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

The two timers conflict

Greeting , Nordic team , i have some questions about my project. First , my hardware and software is following: nrf51422 (pca10028) SDK 9.0 SoftDevice S110

My project is a data logger that fetch the sensor data to mobile phone by BLE and display it on LCD, additionally , using LEDs show the status (connection/log status). It would manually fetch data by press button or automatically. The hardware always in advertising state , if there's no client pairing , still fetch sensor data and showing on LCD.

But the question is after I adding another app_timer for LEDs , the LEDs blinks but the sensor fetching module and BLE transmit working not well at all.

Here's my code: the timer init part

static void timers_init(void)
{
   uint32_t err_code;

  // Initialize timer module.
  APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);

  // create Temperature measurement timers
  app_timer_create(&m_temperature_timer_id,
                            APP_TIMER_MODE_REPEATED,
                            temp_meas_timeout_handler);


  // create LED flashing timers
  app_timer_create(&m_led_timer_id,
                             APP_TIMER_MODE_REPEATED,
                             led_timeout_handler);
}

the timer start part

    static void application_timers_start(void)
    {
       app_timer_start(m_temperature_timer_id, APP_TIMER_TICKS(2000, APP_TIMER_PRESCALER), NULL);
       app_timer_start(m_led_timer_id, APP_TIMER_TICKS(200, APP_TIMER_PRESCALER), NULL);
    }

The procedure would like this : First , initialize needs. Second , start advertising. Third, I declared and defined a global variable as finalData. I put the sensor fetching code in main loop and save the result to finalData. Finally , if the device have found mobile and finish bonding , transmit the data to mobile.

But heres a conflict that the LEDs blinking well , but the transmit data not works even though not connected to mobile.

So please tell me how to solve it ? Thanks! Happy New Year!

Related