WDT Test.
Toolkit:STM Development System
Location:/bipom/devtools/STM32/examples/usd_api
static void vRTCTEST( void *pvParameters ) { (void) pvParameters; ULONG h,m,s,prevTime=0xFFFFFFFF; volatile ULONG time; int isWdtReload = 30; // while(1) { // Wait for the next second while(1) { time = RTC_Get(); if(prevTime == time) vTaskDelay(10); else break; } // prevTime = time; // if (23*3600+59*60+59 < time ) { RTC_Set(0); tprintf("\n\rSetTime->00:00:00"); prevTime = time = 0; } /* Reload IWDG counter */ if(isWdtReload) { WDT_Reset(); /* Decrement 'isWdtReload' to execute IWDG reset finally */ isWdtReload--; } else tprintf("\n\rWait for Reset..."); // h = time 3600; m = (time % 3600) 60; s = (time % 3600) % 60; tprintf("\n\rTime: %02d:%02d:%02d", h, m, s); } } //******************************************************************************** int main(void) { tprintf("\n\rMini-Max/STM32F1"); tprintf("\n\rWDT TEST REV 1.01"); // Print RESET source tprintf("\n\rRESET: "); if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) { tprintf("<Power On> "); } if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) { tprintf("<External> "); } if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET) { tprintf("<Independent Watchdog> "); } if (RCC_GetFlagStatus(RCC_FLAG_WWDGRST) != RESET) { tprintf("<Window Watchdog> "); } if (RCC_GetFlagStatus(RCC_FLAG_LPWRRST) != RESET) { tprintf("<Software> "); } if (RCC_GetFlagStatus(RCC_FLAG_SFTRST) != RESET) { tprintf("<Low Power> "); } /* Clear reset flags */ RCC_ClearFlag(); // Initialize RTC // if RTC_Init returns SUCCESS the RTC is still running with correct time // Otherwise RTC is reset to 00:00:00 // If this occurs set time to 23:59:45 if(SUCCESS != RTC_Init()) RTC_Set(23*3600+59*60+45); // // Initialize WDT to 3 seconds ( MAX VALUE is 26 seconds) WDT_Init(3); /* Check if the system has resumed from IWDG reset */ if(pdPASS != xTaskCreate (vRTCTEST, ( const signed portCHAR * const )"RTCTEST", configMINIMAL_STACK_SIZE<<4, NULL, tskIDLE_PRIORITY, NULL )) { tprintf("\n\rERROR: can't create RTCCTEST task"); } /* Now all the tasks have been started - start the scheduler. */ vTaskStartScheduler(); for(;;); return 0; }