Does pyboard support 3-wire mode SPI bus?

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
shaoziyang
Posts: 138
Joined: Sun Apr 17, 2016 1:55 pm

Does pyboard support 3-wire mode SPI bus?

Postby shaoziyang » Wed Jan 18, 2017 4:48 pm

Does pyboard support 3-wire mode SPI bus?

Standard SPI is 4-wire, MOSI, MISO, SCK and CS. But in some case, we use 3-wire mode SPI, does micropython support it?

3.jpg
3.jpg (25.34 KiB) Viewed 223 times

User avatar
dhylands
Posts: 2387
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: Does pyboard support 3-wire mode SPI bus?

Postby dhylands » Wed Jan 18, 2017 5:14 pm

MicroPython doesn't directly support this, but the reference Manual for the STM32F405 says that it is supported.

So I think that you can make it work by using the stm module to read/write the registers directly to tweak the SPI mode.

Here's an example of using the stm module to set the HDSEL bit in a UART:
https://github.com/dhylands/bioloid3/bl ... ort.py#L27

You should be able to do something similar to play with the SPI registers. The stm module has the following SPI constants:

Code: Select all

>>> import stm
>>> [x for x in dir(stm) if x.startswith('SPI')]
['SPI2', 'SPI3', 'SPI1', 'SPI_CR1', 'SPI_CR2', 'SPI_SR', 'SPI_DR', 'SPI_CRCPR', 'SPI_RXCRCR', 'SPI_TXCRCR', 'SPI_I2SCFGR', 'SPI_I2SPR']
SPI1, SPI2, and SPI3 are the SPI base register addresses and SPI_xxx are the offsets of the various registers.

shaoziyang
Posts: 138
Joined: Sun Apr 17, 2016 1:55 pm

Re: Does pyboard support 3-wire mode SPI bus?

Postby shaoziyang » Thu Jan 19, 2017 2:07 am

dhylands wrote:MicroPython doesn't directly support this, but the reference Manual for the STM32F405 says that it is supported.

So I think that you can make it work by using the stm module to read/write the registers directly to tweak the SPI mode.

Here's an example of using the stm module to set the HDSEL bit in a UART:
https://github.com/dhylands/bioloid3/bl ... ort.py#L27

You should be able to do something similar to play with the SPI registers. The stm module has the following SPI constants:

Code: Select all

>>> import stm
>>> [x for x in dir(stm) if x.startswith('SPI')]
['SPI2', 'SPI3', 'SPI1', 'SPI_CR1', 'SPI_CR2', 'SPI_SR', 'SPI_DR', 'SPI_CRCPR', 'SPI_RXCRCR', 'SPI_TXCRCR', 'SPI_I2SCFGR', 'SPI_I2SPR']
SPI1, SPI2, and SPI3 are the SPI base register addresses and SPI_xxx are the offsets of the various registers.


Thank you !


Return to “Other Boards”

Who is online

Users browsing this forum: No registered users and 2 guests