watchdog timer

Posted on
  • Does espruino have a watchdog timer similar to the arduino? If the device is stalled, it would reset the espruino.

  • Absolutely. According to the datasheet the STM32F103x family of mcu's have 2 watchdog timers. You control them via registers, and you can write register data using the poke8/16/32 functions. Do be careful however. The watchdog counter needs to be reset at your discretion. ie. if you have a program that just sits and wait for an external interrupt (say, a PIR motion sensor), and nothing happens for a while. Then you need to make sure that you counter reset takes place in a setInterval().

    You can see all the register documentaion and much more in the ST reference manual found here.

  • Just thinking aloud here....it's most likely much better to implement this in a library and have the event loop reset the counter?

  • It's a good idea - It could definitely be handled by peek/poke/setInterval

    Ideally it'd just be done in the interpreter though - I've added an issue for it in GitHub: https://github.com/espruino/Espruino/iss­ues/252

    I doubt it would be enabled by default, but it'd be a good thing to allow people to turn it on when they wanted to make sure Espruino kept going...

  • sounds very cool. let me know when this is ready for testing and I'll try it out as soon as I can.

  • It'll be in 1v56 - E.enableWatchdog(timeout_in_seconds). Everything else is done automatically

  • Can we manually handle resetting watchdog instead of Espruino's main loop?

    I want to reset the watchdog manually in order to trigger some action that can only be performed upon boot process.

    My application may response and give control to Espruino's main loop, but that is not sufficient for my purpose. Instead, it should be reset via a data from a socket connection.

  • You can't do that at the moment. It'd be a good addition though - I've just added in issue for it: https://github.com/espruino/Espruino/iss­ues/859

    However, I guess you're expecting to use this on the ESP8266? I'm afraid the watchdog isn't implemented for that.

  • Yes, I would use it on ESP8266. You don't mean it's not implemented by hardware, do you?

  • I mean it's not implemented in the ESP8266's code at the moment.

    I know there's a 1 sec watchdog that is added by the OS - but if that's the only one available then you may not be able to use it from Espruino even if it were implemented

  • Then we have only a separate hardware watchdog IC option for our own purposes (separate from Espruino's main loop)?

  • Assuming that the OS watchdog is not suitable, that may be the case? You might to better interrogating the people who are focused on ESP8266, though. Try asking on gitter maybe?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

watchdog timer

Posted by Avatar for hansamann @hansamann

Actions