Dual SPI on ESP32-WROOM-32E

RonKremborg
Posts: 2
Joined: Tue May 28, 2024 6:36 am

Dual SPI on ESP32-WROOM-32E

Postby RonKremborg » Tue May 28, 2024 7:05 am

In a PlatformIO and Arduino environment, I have 2 SPI devices: An SDCard and a stepper motor controller. The former is SPI_MODE0 and the latter SPI_MODE3. The board I am using (Sparkfun ESP32 RedBoard) does not bring GPIO12 to a connector, so I need to put both devices on VSPI. Here is how I have set it up. The SDCARD code segment is:

Code: Select all

      vSPI.beginTransaction(SPISettings(Motor.GetSpiClk(), MSBFIRST, SPI_MODE0));
      SD.begin(SDCARD_CS, vSPI);
      Card.AppendFile(TheFile, (char*)dataLine);
      SD.end();
      vSPI.endTransaction();
The stepper controller has variable length commands (in count):

Code: Select all

   vSPI.beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE3));
   digitalWrite(STEPPER_CS, LOW);       // enable the powerstep chip select
   i = 0;                              // clear output buffer index
   while (count-- > 0)
   {
      retVal = vSPI.transfer(*ptr);   // transfer in/out
   }
   digitalWrite(STEPPER_CS, HIGH);      // disable the chip select
   vSPI.endTransaction();
However, while the SDCard code works, for the stepper although the CS, MOSI and SCLK lines seem to be working as seen on my scope, no data gets transferred from the stepper controller. I would welcome any advice on what I am doing wrong.
Ron

tanmanh0707
Posts: 17
Joined: Fri Jun 23, 2023 3:26 am

Re: Dual SPI on ESP32-WROOM-32E

Postby tanmanh0707 » Tue May 28, 2024 8:25 am

Since CS, MOSI and SCLK are working on your scope, I doubt the issue is from your stepper. I suggest removing SD card out and check only stepper if it works firstly.

RonKremborg
Posts: 2
Joined: Tue May 28, 2024 6:36 am

Re: Dual SPI on ESP32-WROOM-32E

Postby RonKremborg » Tue May 28, 2024 1:28 pm

Good idea. I'll try that tomorrow.
Regards, Ron

Who is online

Users browsing this forum: No registered users and 32 guests