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

Softdevice assertion failed after some time of advertisment without event

Hello,

I've a very strange problem with the nrf52838 chip in the ISP4520 (https://www.insightsip.com/products/combo-smart-modules/isp4520).

The nrf52832 advertise all the time and after some time the softdevice assert an error. I have a watchdog so the device reeboot all the time.

The restart comes after 2h10 with an advertisement interval of 3000 (so 1875ms) and after 10min with advertisement interval of 32 (so 20ms). I don't find any parameter which correct my problem... This is my initialisation :

#define APP_ADV_INTERVAL                32
#define BLE_UUID_DEVICE_SHORT           0X1900
static uint8_t serial_number[8];
static ble_advdata_manuf_data_t m_advdata_manuf_data;
static ble_uuid_t m_adv_uuids[] =                                               /**< Universally unique service identifiers. */
{
    {BLE_UUID_DEVICE_SHORT, BLE_UUID_TYPE_BLE}
};

static void advertising_init(void)
{
    ret_code_t             err_code;
    ble_advertising_init_t init;

    memset(&init, 0, sizeof(init));

    init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance      = false;
    init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    init.advdata.p_manuf_specific_data	 = &m_advdata_manuf_data;

    lmh_devEui_get(serial_number);
    m_advdata_manuf_data.company_identifier = 0xFFFE;
    m_advdata_manuf_data.data.size = sizeof(serial_number);
    m_advdata_manuf_data.data.p_data = serial_number;

    init.config.ble_adv_on_disconnect_disabled = true;
    init.config.ble_adv_fast_enabled  = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout  = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED;

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

While nrf52832 advertise, there is no event exept ble event. 

With the debug mode, the softdevice assert at Pc 0x00014CBC. I use the sdk 16.0.

Can anyone help me with this problem ?

Valentin

Parents
  • Ok, I don't understand neither... I will do more test to be sure that the bug is gone.
    In the code, I see the macro CRITICAL_REGION_ENTER() and CRITICAL_REGION_EXIT() but an enter is folow by an exit  :

    void TimerStart (TimerEvent_t *obj)
    {
        uint32_t elapsedTime = 0;
    	 
        if ((obj == NULL) || (TimerExists(obj) == true))
        {
            return;
        }
    	
        CRITICAL_REGION_ENTER();
    	
        obj->Timestamp = obj->ReloadValue;
        obj->IsRunning = false;
    
        // First obj in the list
        if (TimerListHead == NULL)
        {
            // enable RTC2 CC[0] interrupts
            NRF_RTC2->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
            NRF_RTC2->INTENSET = RTC_INTENSET_COMPARE0_Msk;
            // Get reference time
            m_rtc_reference_time = RTC2_GetCounterReg();
    		
            // insert a timeout at reference time + obj->Timestamp
            TimerInsertNewHeadTimer(obj); 
        }
    	// Add obj to the list
    	else 
    	{
                elapsedTime = RTC2_GetTimerElapsedTime();
                obj->Timestamp += elapsedTime;
      
                if (obj->Timestamp < TimerListHead->Timestamp)
                {
                    TimerInsertNewHeadTimer(obj);
                }
                else
                {
                    TimerInsertTimer(obj);
                }
    	}
    	
        CRITICAL_REGION_EXIT();
    }
    
    void TimerStop (TimerEvent_t *obj) 
    {
        TimerEvent_t* prev = TimerListHead;
        TimerEvent_t* cur = TimerListHead;
    
        // List is empty or the Obj to stop does not exist 
        if ((TimerListHead == NULL) || (obj == NULL))
        {
            return;
        }
    	
        CRITICAL_REGION_ENTER();
    
        // Stop the Head  
        if(TimerListHead == obj)                 
        {
            // The head is already running 
            if(TimerListHead->IsRunning == true) 
            {    
                // If another obj is registered we switch to it
                if(TimerListHead->Next != NULL)
                {
                    TimerListHead->IsRunning = false;
                    TimerListHead = TimerListHead->Next;
                    TimerSetTimeout(TimerListHead);
                }
                // No other obj registered: we can disable interrupts
                else
                {
                    // Disable RTC2 CC[0] interrupt
                    NRF_RTC2->EVTENSET = RTC_EVTEN_COMPARE0_Disabled;
                    NRF_RTC2->INTENSET = RTC_INTENSET_COMPARE0_Disabled;
                    TimerListHead = NULL;
                }
            }
            // Stop the head before it is started
            else 
            {   
                if(TimerListHead->Next != NULL)   
                {
                    TimerListHead = TimerListHead->Next;
                }
                else
                {
                    TimerListHead = NULL;
                }
            }
        }
        // Stop an object within the list
        else 
        {      
            while (cur != NULL)
            {
                if(cur == obj)
                {
                    if(cur->Next != NULL)
                    {
                        cur = cur->Next;
                        prev->Next = cur;
                    }
                    else
                    {
                        cur = NULL;
                        prev->Next = cur;
                    }
                    break;
                }
                else
                {
    		prev = cur;
                    cur = cur->Next;
                }
            }   
        }
    	
        CRITICAL_REGION_EXIT();
    }  

    I haven't write this code, this is the sdk by insight for ISP4520.
    If I have the bug again, I will post a new message.

    Valentin

Reply
  • Ok, I don't understand neither... I will do more test to be sure that the bug is gone.
    In the code, I see the macro CRITICAL_REGION_ENTER() and CRITICAL_REGION_EXIT() but an enter is folow by an exit  :

    void TimerStart (TimerEvent_t *obj)
    {
        uint32_t elapsedTime = 0;
    	 
        if ((obj == NULL) || (TimerExists(obj) == true))
        {
            return;
        }
    	
        CRITICAL_REGION_ENTER();
    	
        obj->Timestamp = obj->ReloadValue;
        obj->IsRunning = false;
    
        // First obj in the list
        if (TimerListHead == NULL)
        {
            // enable RTC2 CC[0] interrupts
            NRF_RTC2->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
            NRF_RTC2->INTENSET = RTC_INTENSET_COMPARE0_Msk;
            // Get reference time
            m_rtc_reference_time = RTC2_GetCounterReg();
    		
            // insert a timeout at reference time + obj->Timestamp
            TimerInsertNewHeadTimer(obj); 
        }
    	// Add obj to the list
    	else 
    	{
                elapsedTime = RTC2_GetTimerElapsedTime();
                obj->Timestamp += elapsedTime;
      
                if (obj->Timestamp < TimerListHead->Timestamp)
                {
                    TimerInsertNewHeadTimer(obj);
                }
                else
                {
                    TimerInsertTimer(obj);
                }
    	}
    	
        CRITICAL_REGION_EXIT();
    }
    
    void TimerStop (TimerEvent_t *obj) 
    {
        TimerEvent_t* prev = TimerListHead;
        TimerEvent_t* cur = TimerListHead;
    
        // List is empty or the Obj to stop does not exist 
        if ((TimerListHead == NULL) || (obj == NULL))
        {
            return;
        }
    	
        CRITICAL_REGION_ENTER();
    
        // Stop the Head  
        if(TimerListHead == obj)                 
        {
            // The head is already running 
            if(TimerListHead->IsRunning == true) 
            {    
                // If another obj is registered we switch to it
                if(TimerListHead->Next != NULL)
                {
                    TimerListHead->IsRunning = false;
                    TimerListHead = TimerListHead->Next;
                    TimerSetTimeout(TimerListHead);
                }
                // No other obj registered: we can disable interrupts
                else
                {
                    // Disable RTC2 CC[0] interrupt
                    NRF_RTC2->EVTENSET = RTC_EVTEN_COMPARE0_Disabled;
                    NRF_RTC2->INTENSET = RTC_INTENSET_COMPARE0_Disabled;
                    TimerListHead = NULL;
                }
            }
            // Stop the head before it is started
            else 
            {   
                if(TimerListHead->Next != NULL)   
                {
                    TimerListHead = TimerListHead->Next;
                }
                else
                {
                    TimerListHead = NULL;
                }
            }
        }
        // Stop an object within the list
        else 
        {      
            while (cur != NULL)
            {
                if(cur == obj)
                {
                    if(cur->Next != NULL)
                    {
                        cur = cur->Next;
                        prev->Next = cur;
                    }
                    else
                    {
                        cur = NULL;
                        prev->Next = cur;
                    }
                    break;
                }
                else
                {
    		prev = cur;
                    cur = cur->Next;
                }
            }   
        }
    	
        CRITICAL_REGION_EXIT();
    }  

    I haven't write this code, this is the sdk by insight for ISP4520.
    If I have the bug again, I will post a new message.

    Valentin

Children
No Data
Related