adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4k stars 1.18k forks source link

Crash when using countio and pwmio together. #5556

Closed domdfcoding closed 2 years ago

domdfcoding commented 2 years ago

CircuitPython version

Adafruit CircuitPython 7.0.0-651-g5572876d2 on 2021-11-07; Pimoroni Pico LiPo (4MB) with rp2040

Code/REPL

import pwmio, countio, board
print("import OK")
counter = countio.Counter(board.GP1)
print("counter OK")
motor = pwmio.PWMOut(board.GP8)
print("motor OK")

Behavior

$ picocom /dev/ttyACM1
Adafruit CircuitPython 7.0.0-651-g5572876d2 on 2021-11-07; Pimoroni Pico LiPo (4MB) with rp2040
>>> import crash  # the file containing the code above
import OK
counter OK
FATAL: read zero bytes from port
term_exitfunc: reset failed for dev UNKNOWN: Input/output error

The last two lines are from picocom.

Description

When attempting to use countio and pwmio together, the REPL freezes and doesn't respond to Ctrl+C. Eventually picocom drops the connection, and the USB drive becomes unresponsive.

Changing the order (creating motor first then counter) only postpones the crash until setting the duty cycle on motor.

Additional information

Also tried with 7.0.0, with the same result.

I tried changing the pins but it didn't make a difference.

tannewt commented 2 years ago

Does the board restart in safe mode?

dhalbert commented 2 years ago

countio uses PWM internally on RP2040 (unlike on other ports).

dhalbert commented 2 years ago

Fixed by #5667.