Page 1 of 1
Hardware SPI Pins
Posted: Sat Nov 11, 2017 7:53 am
by rdagger
On the ESP32, what are the native GPIO pins for hardware SPI on bus ID 1 and 2?
Re: Hardware SPI Pins
Posted: Sat Nov 11, 2017 5:40 pm
by rdagger
It looks like there are 2 available SPI buses on the ESP32: HSPI=1 and VSPI = 2.
HSPI is MOSI=GPIO13, MISO=GPIO12 and SCK=GPIO14
VSPI is MOSI=GPIO23, MISO=GPIO19 and SCK=GPIO18
However, the machine SPI class does seem to work unless I pass the pin values. For example.
doesn't work with an SSD1351 connected to MOSI=GPIO13 and SCK=GPIO14
also doesn't work with MOSI=GPIO23 and SCK=GPIO18
However, it does work if I specify the GPIO pins as arguments:
Code: Select all
spi = SPI(2, baudrate=12500000, sck=Pin(18), mosi=Pin(23))
The problem is that I don't think this is giving me true hardware performance because I should be getting around 20MHz but the maximum baud rate I can use is 12.5MHz.
Re: Hardware SPI Pins
Posted: Sun Nov 12, 2017 2:58 am
by MrSurly
Hi,
You can use HW SPI with just about any of the pins, but when you use the "native" pins for a particular HW SPI, you should be able to achieve much higher baud rates.
Yes, you must pass the actual Pin() objects.
For HSPI (id = 1), the pins are:
CLK: 14
MOSI: 13
MISO: 12
For VSPI (id = 2):
CLK: 18,
MOSI: 23,
MISO: 19,
Also, are you using a new enough MicroPython that you're not seeing this issue:
https://github.com/micropython/micropyt ... ssues/189
Re: Hardware SPI Pins
Posted: Sun Nov 12, 2017 3:19 am
by rdagger
I'm using today's build. Thanks.