Can't figure out how to use microcontroller.watchdog on MatrixPortal M4

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ceb2120
 
Posts: 10
Joined: Fri Oct 14, 2022 1:33 pm

Can't figure out how to use microcontroller.watchdog on MatrixPortal M4

Post by ceb2120 »

Hello! I've been trying to use the watchdog module using this documentation. I've tried multiple versions of the code and haven't been able to get it to function properly.

When I run the examples from the documentation including this example:

Code: Select all

from microcontroller import watchdog as w
from watchdog import WatchDogMode
w.timeout=2.5 # Set a timeout of 2.5 seconds
w.mode = WatchDogMode.RAISE
w.feed()
or this example:

Code: Select all

import microcontroller 
import watchdog
wtd = microcontroller.watchdog
wtd.timeout=2.5 # Set a timeout of 2.5 seconds
wtd.mode = watchdog.WatchDogMode.RAISE
I get the error:

Code: Select all

Traceback (most recent call last):
  File "code.py", line 2, in <module>
ImportError: no module named 'watchdog'
I've also attempted running it like this:

Code: Select all

import microcontroller 

wtd = microcontroller.watchdog
wtd.timeout=2.5 # Set a timeout of 2.5 seconds
wtd.mode = wtd.WatchDogMode.RAISE
and I get the error:

Code: Select all

Traceback (most recent call last):
  File "code.py", line 4, in <module>
AttributeError: 'NoneType' object has no attribute 'timeout'
Is there an issue with the code I'm running or is watchdog incompatible with the board? I'm unsure of what to do. Thanks!

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: Can't figure out how to use microcontroller.watchdog on MatrixPortal M4

Post by danhalbert »

What version of CircuitPython are you using? The version is given in the boot_out.txt file and in the initial printout in the REPL after you restart.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”