HSPI >26MHz?

JimDrew
Posts: 7
Joined: Sun Jun 14, 2020 10:28 pm

HSPI >26MHz?

Postby JimDrew » Sun Jun 14, 2020 11:12 pm

I have a board setup using both HSPI and VSPI. I am using the dedicated pins for both of these ports.

There are two issues that I can not seem to resolve.

Issue 1 - I can not make the port go any faster than 26MHz. Anything up to 26MHz works fine. The device it is connected to will handle 38MHz, and that has been verified by driving it with a dsPIC33 CPU.

Code: Select all

const int XMISO = 12;                         // (I) GPIO12 - VLSI MISO
const int XMOSI = 13;                         // (O) GPIO13 - VLSI MOSI
const int XSCK = 14;                          // (O) GPIO14 - VLSI SCK
const int XCS = 15;                           // (O) GPIO15 - VLSI /CS

SPIClass SPI2(HSPI);

void  init_VLSI() {
  SPI2.begin(XSCK,XMISO,XMOSI,XCS);           // enable SPI2, used only by VLSI
//  SPI2.beginTransaction(SPISettings(38000000, MSBFIRST, SPI_MODE0));  // 38MHz SPI speed, MSB first, mode 0
  SPI2.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0));  // 26MHz SPI speed, MSB first, mode 0

  digitalWrite(XCS, LOW);                     // bring VLSI CS low
  SPI2.transfer(0x9F);                        // send ID command byte
  VLSI_ID = SPI2.transfer(0x00);              // get ID
  VLSI_TYPE = SPI2.transfer(0x00);            //get type
  digitalWrite(XCS, HIGH);                    // bring VLSI CS high

  Serial.print("VLSI ID:");
  Serial.println(VLSI_ID,HEX);
  Serial.print("VLSI TYPE:");
  Serial.println(VLSI_TYPE,HEX);
}
This code works perfect as long as speed is set to 26000000 or lower. You can see that I am using the default HSPI pinout.

Issue 2 - You can see in the above code that I have to control the CS line manually. I was under the impression that the hardware SPI would control the CS line if you define the line to be used.

I am using the latest ESP32 library for the Arduino setup. Any idea why I am having these issues? I am not sure if VSPI has the same issue because the device connected to it has a maximum speed of 25MHz, so it's setup that way and works fine.

I have tried using just SPI2.begin() without the pin names because of the HSPI class declaration, and that works, but also limited to 26MHz. I tried SPI2.begin(-1,-1,-1,-1) and that also works. The -1 is suppose to be used to tell the ESP32 driver to not use the IO multiplexer.

I am at a loss, and I need the SPI speed to be >26MHz or I can't use this product.

This is on a custom board, but I am using the DOIT DEVKIT 1 as the board type in the Arduino IDE.

Thanks for any insight you can give me!

JimDrew
Posts: 7
Joined: Sun Jun 14, 2020 10:28 pm

Re: HSPI >26MHz?

Postby JimDrew » Sat Jun 20, 2020 9:30 pm

Bump? Doesn't anyone actually use SPI? :)

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: HSPI >26MHz?

Postby lbernstone » Sun Jun 21, 2020 2:43 pm

https://docs.espressif.com/projects/esp ... and-io-mux
AFAICT the arduino hal always uses GPIO matrix.

JimDrew
Posts: 7
Joined: Sun Jun 14, 2020 10:28 pm

Re: HSPI >26MHz?

Postby JimDrew » Tue Jun 23, 2020 1:30 am

Well, that is interesting. Is that actually documented anywhere?

I found this:

"If the Host only writes data, the dummy bit workaround and the frequency check can be disabled by setting the bit SPI_DEVICE_NO_DUMMY in the member spi_device_interface_config_t::flags. When disabled, the output frequency can be 80MHz, even if the GPIO matrix is used."

Any idea how to set this flag using the Arduino IDE? Maybe this would work?

Thanks!

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: HSPI >26MHz?

Postby lbernstone » Tue Jun 23, 2020 2:26 am

The code is open source. You are welcome to change it any way you please.

Who is online

Users browsing this forum: No registered users and 137 guests