← index #11082Issue #16912
Duplicate · high · value 1.972
QUERY · ISSUE

RP2 SPI: Instantiating with spi=None does not behave sensibly.

openby peterhinchopened 2023-03-20updated 2024-09-02
bugport-rp2

The constructor accepts None as an arg to miso, but still instantiates the default pin.

The clear intent is to create an output-only interface. Either it should reject the arg or (preferably) it should not instantiate a pin. Current behaviour can lead to unexpected pin conflicts.

This should also apply to mosi.

CANDIDATE · ISSUE

When miso=None is set, the default miso pin changed state.

openby kaso-0opened 2025-03-11updated 2026-03-25
bugport-rp2

Port, board and/or hardware

Raspberry Pi Pico W

MicroPython version

MicroPython v1.24.1 on 2024-11-29; Raspberry Pi Pico W with RP2040

Reproduction

RS = Pin(16, Pin.OUT)

spi = SPI(0,
baudrate=400000,
polarity=0,
phase=0,
bits=8,
firstbit=SPI.MSB,
sck=Pin(18),
mosi=Pin(19),
miso=None)

RS.value(0)
time.sleep_ms(1)
RS.value(1)

Expected behaviour

Expected to set up SPI without MISO, set the RS pin value to 0, and after 1 ms, set the RS pin value to 1.

Observed behaviour

The SPI was set up correctly, but the RS pin's value never changed.

Additional Information

If I set up the pin after initializing SPI, it works as expected, the used pin 16 is default pin for miso. I think this bug is on other types of RPIs Pico.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied