Other Parts Discussed in Thread: SYSCONFIG
Hello,
I'm using CC2340R5 SDK 7.20 example code basic_ble.
I want to implement watchdog in my current code for my project.
Our application is: BLE wakes up from a GPIO interrupt only and broadcast data and then goes to standby state until the next interrupt occurs.
So, for this application I want to implement watchdog.
I have configured watchdog taking reference from example code of watchdog.
Below is my code :
Here, I'm configuring interrupt as well as watchdog in this function.
void mainThread(void) { /* Configure GPIO pin */ GPIO_setConfig(CONFIG_GPIO_EXT_WAKEUP, GPIO_CFG_IN_PD | GPIO_CFG_IN_INT_FALLING); //Since, low & high value interrupts are not available for Low Power F3 devices // GPIO_setConfig(CONFIG_GPIO_EXT_WAKEUP, GPIO_CFG_IN_INT_FALLING); /* Install GPIO Interrupt callback */ GPIO_setCallback(CONFIG_GPIO_EXT_WAKEUP, gpioButtonFxn0); /* Enable interrupts */ GPIO_enableInt(CONFIG_GPIO_EXT_WAKEUP); //Rushi Watchdog_Params params; // Watchdog_Handle watchdogHandle; /* Call driver init functions */ GPIO_init(); Watchdog_init(); /* Open a Watchdog driver instance */ Watchdog_Params_init(¶ms); params.callbackFxn = (Watchdog_Callback)watchdogCallback; params.debugStallMode = Watchdog_DEBUG_STALL_ON; params.resetMode = Watchdog_RESET_ON; watchdogHandle = Watchdog_open(CONFIG_WATCHDOG_0, ¶ms); if (watchdogHandle == NULL) { /* Error opening Watchdog */ while (1) {} }
This is the callback function of interrupt :
/*Interrupt Callback*/ void gpioButtonFxn0(uint8_t index) { BLEAppUtil_invokeFunctionNoData(enableAdvertising); }
And in this function I'm broadcasting and clearing watchdog.
/*This function enables advertising and does broadcast the TPMS data*/ void enableAdvertising() { bStatus_t status; delay(7000); BLEAppUtil_advStart(broadcasterAdvHandle_1, &broadcasterStartAdvSet1); /*Don't free anything since we're going to use the same buffer to re-load*/ status = GapAdv_prepareLoadByBuffer(advData1, FALSE); if (status == SUCCESS) /* Only update the data when return is successful*/ { SensorMeasure(); uint8_t ADV_DATA2_LEN = sizeof(advData1); /* Reload buffer to handle*/ GapAdv_loadByBuffer(ADV_DATA2_LEN, advData1); } // usleep(SLEEP_US); Watchdog_clear(watchdogHandle); }
declared watchdogHandle globally.
The main issue here is the watchdog gives reset after its timeout even though I've cleared it.
Also, have called the mainthread in main function. And while debugging code does not enter into the callback mentioned above. It gets stuck somewhere in function vTaskStartScheduler();
The watchdog resets continuously after its timeout.