Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Hello @Middleware & OS
My FreeRTOS application experiences sporadic crashes or resets without an obvious cause. What steps can I take, such as enabling stack overflow checking, using watchdog timers, or analyzing core dumps, to investigate and resolve these unexpected system failures? Please provide code examples to help understand these solutions.
// Enabling stack overflow checking
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) {
// Handle stack overflow
printf(“Stack overflow in task: %s\n”, pcTaskName);
while(1); // Stay here to help debugging
}
// Using a watchdog timer
void vTaskWithWatchdog(void *pvParameters) {
for(;;) {
// Refresh watchdog
HAL_IWDG_Refresh(&hiwdg);
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void main(void) {
// Initialize watchdog
IWDG_HandleTypeDef hiwdg;
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_64;
hiwdg.Init.Reload = 0xFFF;
HAL_IWDG_Init(&hiwdg);
xTaskCreate(vTaskWithWatchdog, “Task With Watchdog”, 1000, NULL, 1, NULL);
vTaskStartScheduler();
}
CONTRIBUTE TO THIS THREAD