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);
}
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!