Hello,
I am using nRF52833 based BE33 (Celium Devices) and using nRF52SDK17.0.2. I am trying to implement WDT and expecting to occur its event when the module becomes hang or any unexpected error occurred. I am purposely written the code where BLE is advertising and after every 1 second I am trying to update BLE advertise data below is the code that does this.
void advertising_update(uint8_t loadcellnumber,uint8_t loadcell_data[])
{
uint32_t err;
err= sd_ble_gap_adv_stop(m_advertising.adv_handle);
APP_ERROR_CHECK(err);
switch(loadcellnumber){
case 1:{
loadcellData[0]=loadcell_data[0];
loadcellData[1]=loadcell_data[1];
loadcellData[2]=loadcell_data[2];
loadcellData[3]=loadcell_data[3];
break;
}
case 2:{
loadcellData[4]=loadcell_data[0];
loadcellData[5]=loadcell_data[1];
loadcellData[6]=loadcell_data[2];
loadcellData[7]=loadcell_data[3];
break;
}
case 3:{
loadcellData[8]=loadcell_data[0];
loadcellData[9]=loadcell_data[1];
loadcellData[10]=loadcell_data[2];
loadcellData[11]=loadcell_data[3];
break;
}
}
advertising_init();
advertising_start();
}
WDT code in main.c
#include "nrf_drv_wdt.h"
nrf_drv_wdt_channel_id m_channel_id;
int main(void)
{
//Configure WDT.
nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
err_code = nrf_drv_wdt_init(&config, wdt_event_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
APP_ERROR_CHECK(err_code);
nrf_drv_wdt_enable();
for (;;)
{
idle_state_handle();
nrf_drv_wdt_feed();
}
}
I have added below in sdk_config.h file:
// <e> NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver //========================================================== #ifndef NRFX_WDT_ENABLED #define NRFX_WDT_ENABLED 1 #endif // <o> NRFX_WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode // <1=> Run in SLEEP, Pause in HALT // <8=> Pause in SLEEP, Run in HALT // <9=> Run in SLEEP and HALT // <0=> Pause in SLEEP and HALT #ifndef NRFX_WDT_CONFIG_BEHAVIOUR #define NRFX_WDT_CONFIG_BEHAVIOUR 1 #endif // <o> NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value in ms <1-131072000> #ifndef NRFX_WDT_CONFIG_RELOAD_VALUE #define NRFX_WDT_CONFIG_RELOAD_VALUE 20000 #endif // <o> NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver // <0=> Include WDT IRQ handling // <1=> Remove WDT IRQ handling #ifndef NRFX_WDT_CONFIG_NO_IRQ #define NRFX_WDT_CONFIG_NO_IRQ 0 #endif // <o> NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority // <0=> 0 (highest) // <1=> 1 // <2=> 2 // <3=> 3 // <4=> 4 // <5=> 5 // <6=> 6 // <7=> 7 #ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY #define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 #endif // <e> NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. //========================================================== #ifndef NRFX_WDT_CONFIG_LOG_ENABLED #define NRFX_WDT_CONFIG_LOG_ENABLED 0 #endif // <o> NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level // <0=> Off // <1=> Error // <2=> Warning // <3=> Info // <4=> Debug #ifndef NRFX_WDT_CONFIG_LOG_LEVEL #define NRFX_WDT_CONFIG_LOG_LEVEL 3 #endif // <o> NRFX_WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black // <2=> Red // <3=> Green // <4=> Yellow // <5=> Blue // <6=> Magenta // <7=> Cyan // <8=> White #ifndef NRFX_WDT_CONFIG_INFO_COLOR #define NRFX_WDT_CONFIG_INFO_COLOR 0 #endif // <o> NRFX_WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. // <0=> Default // <1=> Black // <2=> Red // <3=> Green // <4=> Yellow // <5=> Blue // <6=> Magenta // <7=> Cyan // <8=> White #ifndef NRFX_WDT_CONFIG_DEBUG_COLOR #define NRFX_WDT_CONFIG_DEBUG_COLOR 0 #endif // </e>
When when I try to connect to BLE from nRF connect App immediately after 1 seconds below error occurs.
<info> app: GATT ATT MTU on connection 0x0 changed to 247.
<error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at /home/neeraj/Applications/EmbeddedStudio_ARM_Nordic_v568_linux_x64/nRF5SDK1702d674dde/nRF5_SDK_17.0.2_d674dde/examples/peripheral/iotians_device_loadcell/IG_BLE.c:524 (line number 524 is line number 5 in above example)
PC at: 0x0002B885
<error> app: End of error report
Here was I expecting that the WDT event should occur but it was not.
Please help me. Am I expecting wrong? Please correct me if I am wrong.
Thanks and regards,
Neeraj Dhekale