Skip to content

Wrong SPIs typology for ESP32C3 #8192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
mgrenonville opened this issue May 11, 2023 · 2 comments
Open
1 task done

Wrong SPIs typology for ESP32C3 #8192

mgrenonville opened this issue May 11, 2023 · 2 comments
Assignees
Labels
Area: Peripherals API Relates to peripheral's APIs.
Milestone

Comments

@mgrenonville
Copy link

Board

esp32-c3-devkitm-1

Device Description

ESP32-C3 in devkitm-1

Hardware Configuration

Master SPI pins (4 - SCK, 5 - MISO, 6 - MOSI) to a slave module

Version

v2.0.6

IDE Name

PlatformIO

Operating System

Linux

Flash frequency

160Mhz

PSRAM enabled

yes

Upload speed

N/A

Description

According to documentation, ESP32C3 has 2 SPIs peripherals, splitted in SPI0 & SPI1 used for attached flash memory, and SPI2 that is a general purpose SPI controller.

When instanciating a SPI on ESP32C3, the default spi number is FSPI that expands to0. But this is confusing with the documentation that says SPI0 is for flash memory (and is compatible with convention in FSPI).

Other issue is that SPI.begin returns void, and when passing a value larger than SPI_COUNT, we don't get errors. Arduino library for esp8266 returns a boolean with success or failure.

Sketch

#include <SPI.h>
#include <Arduino.h>

#define HSPI_MISO MISO
#define HSPI_MOSI MOSI
#define HSPI_SCLK SCK
#define HSPI_SS 18

static const int spiClk = 100000; // 1 MHz


SPIClass *working = NULL;
SPIClass *notWorking = NULL;

void setup()
{

  Serial.begin(115200);
  Serial.setDebugOutput(true);

  working = new SPIClass();
  //notWorking = new SPIClass(HSPI);
  
  working->begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI);

  working->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  Serial.printf("worked: %i != 0", working->getClockDivider());
  working->endTransaction();

  // set up slave select pins as outputs as the Arduino API
  // doesn't handle automatically pulling SS low
  pinMode(HSPI_SS, OUTPUT); // HSPI SS
}

void loop()
{
  delay(100);
}

Debug Message

Depending on SPIClass, sketch returns getClockDivider() == 0 or a correct value

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.
@mgrenonville mgrenonville added the Status: Awaiting triage Issue is waiting for triage label May 11, 2023
@me-no-dev me-no-dev self-assigned this May 11, 2023
@me-no-dev me-no-dev added this to the 3.0.0 milestone May 11, 2023
@me-no-dev me-no-dev added Area: Peripherals API Relates to peripheral's APIs. and removed Status: Awaiting triage Issue is waiting for triage labels May 11, 2023
@me-no-dev
Copy link
Member

Thanks for the report @mgrenonville . We will look into it for 3.0.0

@VojtechBartoska
Copy link
Contributor

@P-R-O-C-H-Y Please take a look on this, postponing it to 3.1.0 milestone, there are 2 relevant tickets I am closing in favor of this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs.
Projects
Development

No branches or pull requests

6 participants