Question
Change IWDG reload and prescaler live
Posted on June 07, 2013 at 17:32
Following my last post on the subject of flash memory erase vs watchdog I have another concern.
Reading the spec I believe that I may be able to change the prescaler+reload of my watchdog just for the time that the flash perform it's erase operation. When i try to do that it does not seem to work even though the spec seems to says so. Here's the code:I have this method to init the wd:void EnableWatchdog(uint16_t watchTimeMs) {&sharpifdef ENABLE_WATCHDOG // See app.h IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); IWDG_SetPrescaler(IWDG_Prescaler_4); // RTC clock = LSI (40kHz) / 4 = 10kHz IWDG_SetReload(10 * watchTimeMs); // 10 * X / 10kHz = Xms timeout IWDG_WriteAccessCmd(IWDG_WriteAccess_Disable); IWDG_Enable();&sharpendif}During init I call EnableWatchdog(3);Later i will call this:if(IWDG->SR == 0) { SetTP(TP1, Bit_SET); EnableWatchdog(10); timeRti = PCtrl; while((PCtrl - timeRti) < m_msf2rti(5)) { } // Test watchdog SetTP(TP1, Bit_RESET); }The deal with timeRti is only to block the mcu during a specific time to see if watchdog works.So This will block the mcu 5ms and if the watchdog is still 3ms (from init) the mcu will reset non-stop. If the the EnableWatchdog(10); works it will not reset and i will se my tp1 toggle accordingly. I watch IWDG->SR because the spec says i should not update the prescaler or reload if any of the status bits are still set.The mcu resets non-stop. Any thoughts? #stm32-iwdg-watchdog