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

WDT RESET(nrf52840)

Hi frnds,

I am using the ble_central and ble_peripheral code (nrf52840).

i am sending 400 bytes of data to central from peripheral continuously, sometimes the boards get unpaired. if i restart the board then it is being connected. can u please help me to initialize the internal watchdog timer  to reset .

I would request Nordic to look into it and help us to resolve the issue...

Regards,

jagadeesh

Parents Reply Children
  • wdt is restting for every two seconds.

    void wdt_init(void)
    {

    NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | ( WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos);
    NRF_WDT->CRV = 2*32768;
    NRF_WDT->RREN |= WDT_RREN_RR0_Msk;
    NRF_WDT->TASKS_START = 1;
    }

    for(;;){  NRF_WDT->RR[0] = WDT_RR_RR_Reload;}

    i am sending 500bytes from peripheral to central with the time interval of 100 millisecs. for 5 minutes its working fine,but after 5 minutes the unpairing is happening. i tried to initialize wdt ,its restarting for every 2secs. i want wdt to reset only when it is hanged. 

  • As I initially mentioned; adding a watchdog will not change the behavior of your application. It'll just reset if it hangs. You need to debug why it disconnects and see if this is due to an assert or anything else. Enter debug mode and see if you can see why it hangs.

     

    Kind regards,

    Håkon

  • i am sending 400 bytes using access port. if i send the message with 500ms time interval from peripheral to central its working fine. if decrease the time interval below 500ms. its working fine for 1 min and then it hangs(unpaired).

    regards,

    jagadeesh

  • 1/9600 = 104,2 us per bit, and 1042 us per byte (inc. start and stop bit).

    This means that the theoretical minimum time to transfer 400 bytes is 400 * 1.042 = ~416.7 ms. You're likely overflowing your UART buffer.

     

    Have you tried entering debug mode to see where this issue occurs?

     

    Kind regards,

    Håkon

  • i tried changing the baud-rate to 115200 . and tried to send 100 bytes with 50ms time interval but facing same issue.

    uint8_t data_array[512];
    uint16_t uartIndex = 0;
    uint16_t uartSubIdx;
    
    #define BLE_UART_LIMIT 			240 	
    
    void uart_event_handle(app_uart_evt_t * p_event)
    {
    uint32_t current_counter = 0;
    switch (p_event->evt_type)
    {
    case APP_UART_DATA_READY:
    UNUSED_VARIABLE(app_uart_get(&data_array[uartIndex]));
    uartIndex++;
    break;
    
    case APP_UART_COMMUNICATION_ERROR:
    APP_ERROR_HANDLER(p_event->data.error_communication);
    break;
    
    case APP_UART_FIFO_ERROR:
    APP_ERROR_HANDLER(p_event->data.error_code);
    break;
    
    case APP_UART_TX_EMPTY:
    nrf_gpio_pin_clear(TX_D);
    NRF_UART_TASK_STOPTX;
    break;
    
    default:
    break;
    }
    }
    
    
    
    static void nus_data_handler(ble_nus_evt_t * p_evt)
    {
    
    if (p_evt->type == BLE_NUS_EVT_RX_DATA)
    {
    uint32_t err_code;
    uint32_t i;
    uint32_t DATA_LENGTH;
    
    NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
    NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
    
    NRF_UART_TASK_STARTTX;
    nrf_gpio_pin_set(TX_D);
    
    for ( i = 0; i < p_evt->params.rx_data.length; i++)
    { 
    do
    {
    err_code = app_uart_put(p_evt->params.rx_data.p_data[i]);
    if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
    {
    NRF_LOG_ERROR("Failed receiving NUS message. Error 0x%x. ", err_code);
    APP_ERROR_CHECK(err_code);
    }
    
    } while (err_code == NRF_ERROR_BUSY);
    
    }
    }
    }
    
    main(){
    
    
        for (;;) {
                 idle_state_handle();
                              if(uartIndex != 0) {
                       // Delay(130); // delay to capture all byte about 1K
                        Delay(60);
                        NRF_LOG_DEBUG("Ready to send data over BLE NUS");
                        NRF_LOG_HEXDUMP_DEBUG(data_array, uartIndex);
                        uartSubIdx =0;
                       // length=0;
                        do {
                              do	{
                                    if(uartIndex < BLE_UART_LIMIT) length = (uint16_t)uartIndex;
                                    else length = BLE_UART_LIMIT;
                                    err_code = ble_nus_data_send(&m_nus, &data_array[uartSubIdx], &length, m_conn_handle);
                                    if ((err_code != NRF_ERROR_INVALID_STATE) &&
                                            (err_code != NRF_ERROR_RESOURCES) &&
                                            (err_code != NRF_ERROR_NOT_FOUND))	{
                                                          APP_ERROR_CHECK(err_code);
                                     }
                                } while (err_code == NRF_ERROR_RESOURCES);
                                if(uartIndex < BLE_UART_LIMIT) uartIndex = 0;
                                else {
                                      uartIndex = uartIndex - BLE_UART_LIMIT;
                                      uartSubIdx = uartSubIdx + BLE_UART_LIMIT;
                                }
                            } while (uartIndex > 0);
                    }
                    uartIndex = 0;
              }
              
    }
    }

Related