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

FreeRTOS sdk 14.1 example crash on adding simple timer

Hi,

I added one more timer. As soon as the timer expires and it runs the event handler, and then advertising stops, and the firmware crashes.

Could someone please tell my why I get this behavior? The change I made is given below, Full file is attachedmain.c:

diff --git a/examples/ble_peripheral/ble_app_hrs_freertos/main.c b/examples/ble_peripheral/ble_app_hrs_freertos/main.c
index bb3df17..9a93b47 100644
--- a/examples/ble_peripheral/ble_app_hrs_freertos/main.c
+++ b/examples/ble_peripheral/ble_app_hrs_freertos/main.c
@@ -156,6 +156,7 @@ static ble_uuid_t m_adv_uuids[] =                                   /**< Univers
     {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}
 };
 
+static TimerHandle_t m_test_timer;                               /**< Definition of battery timer. */
 static TimerHandle_t m_battery_timer;                               /**< Definition of battery timer. */
 static TimerHandle_t m_heart_rate_timer;                            /**< Definition of heart rate timer. */
 static TimerHandle_t m_rr_interval_timer;                           /**< Definition of RR interval timer. */
@@ -307,6 +308,12 @@ static void battery_level_update(void)
     }
 }
 
+static void test_timeout_handler(TimerHandle_t xTimer)
+{
+    UNUSED_PARAMETER(xTimer);
+    NRF_LOG_DEBUG("Test timeout");
+    NRF_LOG_FLUSH();
+}
 
 /**@brief Function for handling the Battery measurement timer time-out.
  *
@@ -409,6 +416,12 @@ static void timers_init(void)
     APP_ERROR_CHECK(err_code);
 
     // Create timers.
+
+    m_test_timer = xTimerCreate("TEST",
+                                   BATTERY_LEVEL_MEAS_INTERVAL,
+                                   pdTRUE,
+                                   NULL,
+                                   test_timeout_handler);
     m_battery_timer = xTimerCreate("BATT",
                                    BATTERY_LEVEL_MEAS_INTERVAL,
                                    pdTRUE,
@@ -577,6 +590,10 @@ static void sensor_simulator_init(void)
 static void application_timers_start(void)
 {
     // Start application timers.
+    if (pdPASS != xTimerStart(m_test_timer, OSTIMER_WAIT_FOR_QUEUE))
+    {
+        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
+    }
     if (pdPASS != xTimerStart(m_battery_timer, OSTIMER_WAIT_FOR_QUEUE))
     {
         APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
Related