What are ESP32 SPI Ports for Micropython SPI(1)?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: What are ESP32 SPI Ports for Micropython SPI(1)?

Post by loboris » Sun Mar 11, 2018 8:25 pm

@mosi

Code: Select all

E (240684) gpio: gpio_set_direction(247): GPIO number error
is issued because you have not declared the CS pin, it doesn't mean the spi is not functioning properly,
This is fixed now and will be commited tomorrow.
If you initialize the spi like this:

Code: Select all

spi = machine.SPI(2, baudrate=32000000, sck=sck, mosi=mosi, miso=miso, cs=cs)
there will be no error.

Both HSPI & VSPI can be used if the sdcard is not configured in SPI mode, but in 1-line or 4-line SD mode.
VSPI is not available if the psRAM is configured to run at 80 MHz.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: What are ESP32 SPI Ports for Micropython SPI(1)?

Post by devnull » Wed May 16, 2018 11:39 pm

How can I set SPI to half-duplex to achieve full speed, I don't see any configuration options for this ?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: What are ESP32 SPI Ports for Micropython SPI(1)?

Post by pythoncoder » Thu May 17, 2018 7:07 am

I don't think SPI has any concept of full or half duplex. You might like to read this Wikipedia article which explains the interface.
Peter Hinch
Index to my micropython libraries.

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: What are ESP32 SPI Ports for Micropython SPI(1)?

Post by loboris » Thu May 17, 2018 8:28 am

pythoncoder wrote:
Thu May 17, 2018 7:07 am
I don't think SPI has any concept of full or half duplex. You might like to read this Wikipedia article which explains the interface.
On ESP32 (spi-master driver) SPI does have the concept of full and half duplex. Of course, it is just driver related and does not affect how SPI phisical interface works.
In full duplex mode the data are written (on MOSI pin) and read (on MISO pin) on the same clock transition.
In half duplex mode the master has two independent phases, write (first, outputs on MOSI, nothing is read) and read (second, reads from MISO, MOSI is held high).
Different SPI peripherals (devices) may require one or the other mode.
For more detailes, see the esp-idf documentation.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: What are ESP32 SPI Ports for Micropython SPI(1)?

Post by devnull » Thu May 17, 2018 9:37 am

Hi, thanks for the help.

OK, so I am using the ESP32, but when I try and set a speed above 26mhz (using native SPI pins) I get a warning that full speed can only be achieved when using half-duplex.

Code: Select all

E (24512) spi_master: spi_bus_add_device(263): No speeds >26MHz supported for full-duplex, GPIO-matrix SPI transfers
So how can I enable half-duplex and achieve 40 & 80 mhz spi speed (on native pins) ?

Thanks

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: What are ESP32 SPI Ports for Micropython SPI(1)?

Post by devnull » Thu May 17, 2018 9:50 am

OK, my bad - I did not set the correct uart #, I was using 1 instead of 2:

Code: Select all

SPI(id=2, baudrate=80000000, polarity=0, phase=0, bits=8, firstbit=0, sck=18, mosi=23, miso=19)
This does not error any more !

Sorry about that !

Post Reply