adafruit / circuitpython

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

metro-m4 call to PDMIn.record() never returns #5797

Closed rsbohn closed 2 years ago

rsbohn commented 2 years ago

CircuitPython version

Adafruit CircuitPython 7.1.0-rc.0 on 2021-12-23; Adafruit Metro M4 Express with samd51j19

Code/REPL

# testing pdm mic
import time
import board
from ulab import numpy as np
from audiobusio import PDMIn, I2SOut
from neopixel import NeoPixel

neo = NeoPixel(board.NEOPIXEL, 1, brightness=0.1)
YELLOW = 0xFFFF00
RED = 0xFF0000
GREEN = 0x00FF00

# M4 I2S pins are fixed
mic = PDMIn(clock_pin=board.D3, data_pin=board.D1,
    sample_rate=16000, bit_depth=16)

buffer = np.zeros(256, dtype=np.uint16)
while True:
    neo[0] = YELLOW
    time.sleep(1)
    neo[0] = RED
    mic.record(buffer, len(buffer))
    neo[0] = GREEN
    time.sleep(5)

Behavior

Expected: NeoPixel is yellow in warmup, red while recording, then green.

Actual: NeoPixel is yellow, then sticks on red.

Call to mic.record() never returns.

I can still read and write the CIRCUITPY drive, but I have to reset the board to break out of mic.record().

This works as expected with 7.0.0, but hangs as documented here on anything after 7.1.0-rc.0.

Description

No response

Additional information

No response

rsbohn commented 2 years ago

Same code, modulo pin assignments, works on latest Feather RP2040.

rsbohn commented 2 years ago

I think @dhalbert mentioned this in the CircuitPython Weekly earlier today.

rsbohn commented 2 years ago

Loaded new build, works as expected! Thank you.

rsbohn commented 2 years ago

[just a sighting] Metro M4 board stuck in PDMIn.record() sometime during file access (circup update --all).