Skip to content

STM32: SPI Issues #3097

@S4WRXTTCS

Description

@S4WRXTTCS

I'm having two issues with the SPI functionality on the STM32F405 Feather Express board running Circuit Python 5.3.

The first issue is that it seems to be leaving an old value in the buffer. For example if I connect a wire from 3.3V to the MISO pin, and then I run the following

>>> import board
>>> import busio
>>> spi = busio.SPI(board.SCK, MISO=board.MISO)
>>> spi.try_lock()
True
>>> spi.configure(baudrate=5000000, phase=0, polarity=0, bits=8)
>>> result = bytearray(1)
>>> spi.readinto(result)
>>> result
bytearray(b'\xff')

That's the correct value, and now I switch the wire from 3.3V to GND.

>>> spi.readinto(result)
>>> result
bytearray(b'\xff')

That's the incorrect value so I read it again.

>>> spi.readinto(result)
>>> result
bytearray(b'\x00')

Which is the correct value. Is there a bug with it or am I doing something stupid?
My initial troubleshooting effort was to switch the baudrate but nothing I tried seemed to work. I tried reducing the baudrate to 1MHz, and it halted as soon as I did the spi.readinto command. I also tried reducing it to 500KHz, and that also halted.

Is there a list of supported baud rates?

I didn't see it here.
https://circuitpython.readthedocs.io/en/5.3.x/shared-bindings/busio/SPI.html

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions