Skip to content

ESP32 C3 Wroom SPI, nothing on MOSI or SCK pins #6252

@TLS1000

Description

@TLS1000

Board

ESP32 c3 Wroom

Device Description

USB to ttl converter sparkfun

Hardware Configuration

/

Version

v2.0.2

IDE Name

1.8.16

Operating System

win10

Flash frequency

80

PSRAM enabled

no

Upload speed

912200

Description

Hi, for testing purpose I wanted to send out some dummy bytes on SPI and see on logic analyser some some flanks. The problem: I get nothing on SCK or MOSI. Suspicious: the 'Serial.println(hspi->pinSS());' returns -1 (although I sent '8' in the construct) so is is there a problem with the spi.begin? I have the impression that something is happening in the background because when I send just a few bytes, or a block of 500 bytes, the CS pin is held low for longer period of time.

Sketch

#include <SPI.h>

#define afeEN 9


#define afeCS 8
#define MOSI 6
#define MISO 5
#define SCLK 4



static const int spiClk = 1000000; // 1 MHz
SPIClass * hspi = NULL;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(afeEN,OUTPUT);
  pinMode(afeCS,OUTPUT);
  digitalWrite(afeEN,true); //enable the AFE
  hspi = new SPIClass(HSPI);
  
  hspi->begin(SCLK, MISO, MOSI, afeCS); //SCLK, MISO, MOSI, SS    SPI lib does not do slave select!
  hspi->setHwCs(false);
  //pinMode(hspi->pinSS(),OUTPUT);
  Serial.println(hspi->pinSS());
  }

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Hello world");
  Serial.println(hspi->pinSS());
  spiCommand(hspi,0x00);
  Serial.println();
  delay(500);
  
  
}

void spiCommand(SPIClass *spi, uint32_t data) {
  //use it as you would the regular arduino SPI API
  spi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(afeCS, LOW); //pull SS slow to prep other end for transfer
  //Serial.println(spi->pinSS());
  //spi->transfer(data);
  //long ak35Data = 0;
  byte spiData  = 0x0F;
  for(int i=0;i<512;i++){
    spi->transfer(spiData);  
  }
  
  
  //delay(10);
  digitalWrite(afeCS, HIGH); //pull ss high to signify end of data transfer
  spi->endTransaction();
  
}

Debug Message

/

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions