I am new to microcontrollers, so please be patient.
I was looking at some of the esp32-C3 data sheets and have some questions. The data sheets for SPI 2 (which is the general purpose SPI has FSPICLK as GPIO6 which is what I assume the “default” for my SPI clock (SCK). FSPIHD (MOSI) is GPIO 4. However when running the following code:
Code: Select all
Serial.begin(115200);
Serial.print("MOSI: ");
Serial.println(MOSI);
Serial.print("MISO: ");
Serial.println(MISO);
Serial.print("SCK: ");
Serial.println(SCK);
Serial.print("SS: ");
Serial.println(SS);
— Terminal on COM4 | 115200 8-N-1
— Available filters and text transformations: colorize,
debug, default, direct, esp32_exception_decoder, hexlify,
log2file, nocontrol, printable, send_on_enter, time
— More details at Redirecting...
— Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x2000082c
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710
MOSI: 4
MISO: 3
SCK: 2
SS: 5
MOSI is where I would expect (GPIO 4 ) but SCK is GPIO 2.
I understand the gpio peripheral pins for general purpose SPI can be reconfigured but I always thought that the default values were considered the “hardware” SPI and if I reconfigure the GPIO matrix - that is considered software SPI and it is slower. I do recall at one point trying to change my SPI settings via commands in the SPI.h library but it really slowed down the frames per second (I am using an SPI oled display).
However, maybe remapping the pins via the GPIO matrix/IOMUX pins is o.k.? So the question is: How did my SCK pin get mapped to GPIO2? Is it “firmware” for my board i.e. this in my output:
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x2000082c
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710
I am not familiar with bootloaders - but could it be that commands in my board's bootloader is changing the default GPIO mappings?
If so, how would I be able to look at my board's bootloader? (I am using a Lolin esp32-C3 pico). Also...how can I change the GPIO matrix mappings? That would REALLY be good to know.
Thank you if you stuck with me this far!
Fish
Fish