setup watchdog early on
This commit is contained in:
parent
a3d838e665
commit
c54728241c
18
main.c
18
main.c
@ -145,12 +145,18 @@ void main(void)
|
||||
{
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz(); // use 8 MHz high speed external clock to generate 72 MHz internal clock
|
||||
|
||||
|
||||
#if DEBUG
|
||||
// enable functionalities for easier debug
|
||||
DBGMCU_CR |= DBGMCU_CR_IWDG_STOP; // stop independent watchdog counter when code is halted
|
||||
DBGMCU_CR |= DBGMCU_CR_WWDG_STOP; // stop window watchdog counter when code is halted
|
||||
DBGMCU_CR |= DBGMCU_CR_STANDBY; // allow debug also in standby mode (keep digital part and clock powered)
|
||||
DBGMCU_CR |= DBGMCU_CR_STOP; // allow debug also in stop mode (keep clock powered)
|
||||
DBGMCU_CR |= DBGMCU_CR_SLEEP; // allow debug also in sleep mode (keep clock powered)
|
||||
#else if !(DEBUG)
|
||||
// setup watchdog to reset in case we get stuck (i.e. when an error occurred)
|
||||
iwdg_set_period_ms(WATCHDOG_PERIOD); // set independent watchdog period
|
||||
iwdg_start(); // start independent watchdog
|
||||
#endif
|
||||
|
||||
// setup board
|
||||
@ -165,6 +171,18 @@ void main(void)
|
||||
// minimal setup ready
|
||||
printf("welcome to the STM32F1 CuVoodoo example code\n"); // print welcome message
|
||||
|
||||
#if !(DEBUG)
|
||||
// show watchdog information
|
||||
printf("watchdog set to (%.2fs)\n",WATCHDOG_PERIOD/1000.0);
|
||||
if (FLASH_OBR&FLASH_OBR_OPTERR) {
|
||||
printf("option bytes not set in flash: software wachtdog used (not started at reset)\n");
|
||||
} else if (FLASH_OBR&FLASH_OBR_WDG_SW) {
|
||||
printf("software wachtdog used (not started at reset)\n");
|
||||
} else {
|
||||
printf("hardware wachtdog used (started at reset)\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// setup RTC
|
||||
printf("setup internal RTC: ");
|
||||
rtc_auto_awake(RCC_LSE, 32768-1); // ensure internal RTC is on, uses the 32.678 kHz LSE, and the prescale is set to our tick speed, else update backup registers accordingly (power off the micro-controller for the change to take effect)
|
||||
|
Loading…
Reference in New Issue
Block a user