Tool/software: TI-RTOS
I'm trying to modify my error handler to use the flash driver rather than the NVS library, since I believe if there is a hard fault the semaphores required for this to operate will not work.
I managed to get the flash driver working, but I noticed when I removed the now redundant NVS functions my watchdog clock will fail to start, causing a WDT timeout and system reset. Even if I leave in the initialisation but comment out only the first NVS_Read() function the clock will still fail to run.
My task initialisation is below:
void ErrorHandlerTask_init(void)
{
Event_Params eventParam;
Event_Params_init(&eventParam);
Event_construct(&errorHandlerEvent, &eventParam);
errorHandlerEventHandle = Event_handle(&errorHandlerEvent);
/* Create the node task */
Task_Params_init(&errorHandlerTaskParams);
errorHandlerTaskParams.stackSize = ERROR_HANDLER_TASK_STACK_SIZE;
errorHandlerTaskParams.priority = ERROR_HANDLER_TASK_PRIORITY;
errorHandlerTaskParams.stack = &errorHandlerTaskStack;
Task_construct(&errorHandlerTask, errorHandlerTaskFunction, &errorHandlerTaskParams, NULL);
/* initialise watchdog */
Watchdog_Params wdParams;
Watchdog_init();
Watchdog_Params_init(&wdParams);
wdParams.callbackFxn = (Watchdog_Callback)watchdogCallback;
wdParams.resetMode = Watchdog_RESET_OFF;
watchdogHandle = Watchdog_open(Board_WATCHDOG0, &wdParams);
if (watchdogHandle == NULL) {
/* Error opening Watchdog */
}
// Calculate the watchdock reload value
uint32_t reloadValue = Watchdog_convertMsToTicks(watchdogHandle, WATCHDOG_TIMEOUT_MS);
// Update reload value
if (reloadValue != 0) {
Watchdog_setReload(watchdogHandle, reloadValue);
}
// Clock for clearing WDT
Clock_Params clkParams;
clkParams.period = 2500 * (1000 / Clock_tickPeriod);
clkParams.startFlag = TRUE;
Clock_construct(&clearWatchdogClock, clearWatchdogClockCallback, clkParams.period, &clkParams);
clearWatchdogClockHandle = Clock_handle(&clearWatchdogClock);
// Initialise NVS params, and read error contents
NVS_Params_init(&nvsErrParams);
nvsErrHandle = NVS_open(1, &nvsErrParams);
if (nvsErrHandle == NULL) {
}
// Read what we've got stored
uint32_t status = NVS_read(nvsErrHandle, 0, &errors, sizeof(errors)); //// IF I REMOVE EVEN THIS THE CLOCK WILL NOT RUN
if(status != NVS_STATUS_SUCCESS){
}
readErrorsFromFlash(); // NEW FUNCTION TO REPLACE THE NVS_READ ABOVE
// Initialise if it's the first run
if(errors.initialised != 0xCC){
memset(&errors, 0, sizeof(errors));
errors.initialised = 0xCC;
writeErrorsToFlash();
}
}
I think it's fairly safe to run both the NVS and Flash in parallel to test here since they utilise different memory locations.
I'm really confused about what's going on here, because it seems the clock isn't stopped by the lack fo NVS function calls after the clock's initialisation, it just entirely fails to start.
What could be going on here?