Skip to main content
Associate III
February 10, 2024
Question

IWDG STM8

  • February 10, 2024
  • 1 reply
  • 2810 views

Hello,

STM8S208RB microcontroller, Independent watchdog (IWDG). After starting the watchdog timer (command KEY_ENABLE value = 0xCC), I understand that the watchdog timer stops after resetting the microcontroller. The default register state is undefined (see figure below). Could it be that after resetting the microcontroller the watchdog timer will be turned on? How can a watchdog timer be stopped while a program is running on a microcontroller? The key register (IWDG_KR) does not have a watchdog stop command (see figure below).

MykolaLevun_0-1707560153755.png

 

    This topic has been closed for replies.

    1 reply

    AScha.3
    Super User
    February 10, 2024

    Hi,

    >The default register state is undefined (see figure below)

    You misunderstanding : the register is "w" , write only - so you cannot read and this means "undefined".

    Its only for write a command, like CC for enable.

     

    >Could it be that after resetting the microcontroller the watchdog timer will be turned on?

    no.

     

    >How can a watchdog timer be stopped while a program is running 

    Usually not at all. Thats what the watchdog is for : unstoppable watch-clock, that resets the cpu in case of a "hanging" program.

    If you want something to start and stop anytime, just use a timer.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    Associate III
    February 10, 2024

    Hello,

    If I enabled the watchdog timer, then reset the microcontroller. After the reset, will the watchdog timer be enabled or disabled?

    AScha.3
    Super User
    February 10, 2024

    At /after reset we have a new program start and no watchdog running - you never could run a program, if always the watchdog resets it again and again - you never could stop this.

    So dont ever start the watchdog, if you anyway want debug and build on your program;

    the watchdog will be useful, if your program is almost finished and working as you want - and then you want some 

    added security , if something you didnt expect happens and your program "hang up" : after some time (you set the useful limit) the watchdog kicks in and restarts the cpu ...better luck this time . :)

     

    "If you feel a post has answered your question, please click ""Accept as Solution""."