AttributeError: 'I2S' object has no attribute 'irq'

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
grg
Posts: 2
Joined: Fri Feb 18, 2022 2:50 pm

AttributeError: 'I2S' object has no attribute 'irq'

Post by grg » Fri Feb 18, 2022 3:13 pm

Working from example code at https://github.com/miketeachman/micropy ... locking.py
Problem replicated with two uf2 firmware images:
Official Raspberry Pi Pico UF2: MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
My version built from a clean clone of the micropython git: MicroPython v1.18-141-gff9c70850 on 2022-02-18; Raspberry Pi Pico with RP2040

Code: Select all

    audioOut = I2S(
        I2D_ID,
        sck=Pin(bclk),
        ws=Pin(wsel),
        sd=Pin(din),
        mode=I2S.TX,
        bits=SAMPLE_SIZE_BITS,
        format=FORMAT,
        rate=SAMPLE_RATE_HZ,
        ibuf=I2S_BUFFER_BYTES
    )
    audioOut.irq = i2s_callback
Generates the error:

Code: Select all

AttributeError: 'I2S' object has no attribute 'irq'
I can get sound playing by writing samples like the play_tone example, I just can't set the irq.

I can see the

Code: Select all

machine_i2s_irq
function in machine_i2s.c, and the

Code: Select all

{ MP_ROM_QSTR(MP_QSTR_irq),             MP_ROM_PTR(&machine_i2s_irq_obj) },
line later on linking it into the locals dict table.

I also see

Code: Select all

[ 68%] Building C object CMakeFiles/firmware.dir/machine_i2s.c.obj
in the firmware build logs.

Google gave me nothing.

I am 110% sure I've done something stupid, it's just...I am totally at a loss for what to try next. Pls help. :(

grg
Posts: 2
Joined: Fri Feb 18, 2022 2:50 pm

Re: AttributeError: 'I2S' object has no attribute 'irq'

Post by grg » Fri Feb 18, 2022 3:22 pm

DOH. I knew I'd find the problem as soon as I posted it.

Code: Select all

audioOut.irq = i2s_callback
should be

Code: Select all

audioOut.irq(i2s_callback)
:roll:

:oops:

Post Reply