AnsweredAssumed Answered

Change IWDG reload and prescaler live

Question asked by Gornstar on Jun 7, 2013
Latest reply on Aug 21, 2013 by Mr_M_from_G
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) {
#ifdef ENABLE_WATCHDOG     // See app.h
     IWDG_SetPrescaler(IWDG_Prescaler_4);     // RTC clock = LSI (40kHz) / 4 = 10kHz
     IWDG_SetReload(10 * watchTimeMs);          // 10 * X / 10kHz = Xms timeout


During init I call EnableWatchdog(3);
Later i will call this:

if(IWDG->SR == 0) {
          SetTP(TP1, Bit_SET);
          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?