adafruit / Adafruit_WICED_Arduino

Adafruit WICED Feather Arduino BSP
https://www.adafruit.com/products/3056
27 stars 19 forks source link

Reconnecting Feather WICED to Wifi #83

Open danielcompton opened 6 years ago

danielcompton commented 6 years ago

This is just a tracking issue to follow along for https://forums.adafruit.com/viewtopic.php?f=57&t=114903. As best as I could tell it still hasn't been resolved, although there is a workaround provided of using a watchdog timer to reset the board if it hangs. More info on watchdog timers at http://librambutan.readthedocs.io/en/latest/libmaple/api/iwdg.html.

#include <iwdg.h>

// ...

// turn on to recover after hang
boolean useWDT = true;

void setup()
{
  //...

   if( useWDT )
  {
    iwdg_init(IWDG_PRE_128, 11500000);
  }
}

void loop()
{
// ...
  # Call this to reset the watchdog timer.
  # If it isn't called then the board will reset.
  iwdg_feed();

}
dabrams commented 6 years ago

The Watch Dog Timer in the STM32F205 is only 12 bits with an 8 bit prescaler. See https://www.st.com/resource/en/datasheet/stm32f205rb.pdf

"3.20.4 Independent watchdog The independent watchdog is based on a 12-bit downcounter and 8-bit prescaler. It is clocked from an independent 32 kHz internal RC and as it operates independently from the main clock, "

so

iwdg_init(IWDG_PRE_128, 11500000); // does not make sense

While idwg.h shows:

void iwdg_init(iwdg_prescaler prescaler, uint16 reload)

only the lower 12 bits of the 16-bit reload value are used.

The longest WDT delay is

iwdg_init(IWDG_PRE_256, 0xfff);

This gives a time out of 1/32kHz 256 4095 or about 32.8 seconds.