iwdg_init() and iwdg_feed()

Post here first, or if you can't find a relevant section!
pico
Posts: 73
Joined: Thu May 07, 2015 4:33 pm

iwdg_init() and iwdg_feed()

Post by pico » Thu May 21, 2015 4:23 pm

Has anyone yet tested these libmaple independent watchdog functions as working for sketches built with IDE 1.6.x?

User avatar
RogerClark
Posts: 7173
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: iwdg_init() and iwdg_feed()

Post by RogerClark » Thu May 21, 2015 8:44 pm

I don't recall anyone ever mentioning either of these

Can you elaborate on their function ?

User avatar
mrburnette
Posts: 1829
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: iwdg_init() and iwdg_feed()

Post by mrburnette » Thu May 21, 2015 11:38 pm

RogerClark wrote:I don't recall anyone ever mentioning either of these

Can you elaborate on their function ?

@Roger: http://leaflabs.com/docs/libmaple/api/iwdg.html

Ray

User avatar
RogerClark
Posts: 7173
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: iwdg_init() and iwdg_feed()

Post by RogerClark » Thu May 21, 2015 11:52 pm

Ray

Thanks for that.

I don't recall anyone every testing those functions.

pico
Posts: 73
Joined: Thu May 07, 2015 4:33 pm

Re: iwdg_init() and iwdg_feed()

Post by pico » Fri May 22, 2015 5:18 am

RogerClark wrote:Ray

Thanks for that.

I don't recall anyone every testing those functions.
Are there other functions perhaps that people are using for their watch dog timers?

User avatar
RogerClark
Posts: 7173
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: iwdg_init() and iwdg_feed()

Post by RogerClark » Fri May 22, 2015 5:34 am

@pico

Looking in the source code, those are the only two functions in iwdg.c, which is described as "Independent watchdog (IWDG) support"

So I suspect thats it, in terms of what was implemented by LeafLabs. That doesnt mean to say the STM32 doesn't have more funky stuff it can do,
We are really just scratching the surface of its functionality in a lot of places ;-)

pico
Posts: 73
Joined: Thu May 07, 2015 4:33 pm

Re: iwdg_init() and iwdg_feed()

Post by pico » Fri May 22, 2015 6:25 am

Fair enough -- I suppose there's a good chance it would all "just work" then. They were the wdt functions I was familiar with back in the old Maple 0.18 days... I was just wondering if people were still using these after the maplelib port.

Perhaps using a wdt less common than I assume? I tend to think of it as fairly basic functionality (although I know in the Arduino world for a long time wdt were considered too "dangerous" for beginners, and early bootloaders didn't support it.)

And even the Due to this day doesn't support wdt without a bit of hacking of the core files! (although I believe Bob Cousins has had a pull request accepted that should make it possible "out of the box" starting with IDE 1.6.5).

Here's a little test sketch that should test whether it's been implemented... unfortunately I don't have convenient access to a Maple clone to test it right now (but I have some mini clones on order). But if someone wants to run it and see whether it resets after 8 seconds, I would appreciate it!

Code: Select all

#include <libmaple/iwdg.h>

int snacks = 5;

void setup() {
  Serial.begin(115200);
  delay(4000); // allow a few secs to establish serial connection and open serial window
  iwdg_init(IWDG_PRE_256, 1250); // init an 8 second wd timer
  Serial.println("\r\nhmm, that's a mean looking dog!");
}

void loop() {
  if (snacks > 0) {
    Serial.println("nice doggy, here's a snack");
    iwdg_feed();
    --snacks;
  }
  else {
    Serial.println("uh oh, I've run out of snacks...");
  }
  delay(1000);
}
Last edited by pico on Fri May 22, 2015 5:42 pm, edited 2 times in total.

User avatar
RogerClark
Posts: 7173
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: iwdg_init() and iwdg_feed()

Post by RogerClark » Fri May 22, 2015 6:52 am

Yes

It resets after 8 secs on a maple mini

nice doggy, here's a snack
nice doggy, here's a snack
uh oh, I've run out of snacks...
uh oh, I've run out of snacks...
uh oh, I've run out of snacks...
uh oh, I've run out of snacks...
uh oh, I've run out of snacks...
uh oh, I've run out of snacks...
uh oh, I've run out of snacks...
I'm not sure I'm seeing things from the start, as its hard to get to the serial monitor in time


PS. Should work on any STM32 won't it ???

PPS.

I guess we should include that header in the core headers or perhaps wrap those core functions in some nice name??

pico
Posts: 73
Joined: Thu May 07, 2015 4:33 pm

Re: iwdg_init() and iwdg_feed()

Post by pico » Fri May 22, 2015 7:32 am

Thanks Roger... that looks like it's resetting after 8s of "no snacks". 8-) (Probably should have put a delay in the setup before the first message to give it time to reestablish the serial connection and to open the window.)

I can't remember if it used to be that you had to include the iwdg.h header explicity in your sketch or not, but I seem to think that may have been the case. Probably no downside in including it automatically, however, given the guard #ifdefs in iwdg.h.

Not sure if it will work on any stm32 device, but it wouldn't surprise me if it did. The iwdg with a 40KHz timer is pretty standard across a range of devices, I believe, so I would expect all the registers would be accessible by the same name across devices.
Last edited by pico on Fri May 22, 2015 8:02 am, edited 1 time in total.

User avatar
RogerClark
Posts: 7173
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: iwdg_init() and iwdg_feed()

Post by RogerClark » Fri May 22, 2015 8:01 am

I just tested it

And it needs the include

I'll include it in Arduino.h or similar do that you wont need to include it

Post Reply