Interpreting Graphical Datasheets - Page 1
Forum section: electronics / beginners

author: ChucktheEE
author_rank: Newbie
timestamp: May 23, 2025, 07:07:04 pm
content: Hello,Attached is a picture of the graphical datasheet for the SparkFun ESP32 thing plus I'm currently working with. I am largely self taught, so I apologize if this is a dumb question. I am currently working on hooking an Adafruit qspi dip breakout board - w25q128 - 128mbit 16 mbyte (w25q128jvsiq) to the ESP32 via SPI for long-term logging. My understanding is that SPI pins have a hardware component and not just any GPIO pin will work. Because of this I was looking and the graphical datasheet to see which pins would be compatible with SPI. This is where I'm having some confusion.If you'll look at the attached image, you'll notice that pin 18 is labeled MOSI. However, it's also labeled V_SPI_CLK. My understanding is that V_SPI_CLK is the label for SCK, not MOSI. How do I interpret data sheets like this? Is the specific function of the SPI irrelevant as long as it's a SPI pin? Can I use any SPI pin and just configure it in the firmware?Thank you for your help.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 23, 2025, 08:13:15 pm
content: I don't have experience with ESP32, but I do have some (limited) experience with STM32.In STM32 Each I/O pin has a multiplexer with up to 8 different functions, and each peripheral (UsART, SPI, I2C) can be routed to 2 or sometimes 3 different I/O pins. So there are a lot of options, but you can't route any peripheral to any pin.If you use a framework like arduino (no capital from me) then there may be extra limitations. Sometimes designers don't have enough interest to make all options that the hardware is capable of available in their configuration. This may also be a deliberate choice to keep for example a connector pinout compatible with other boards to maintain compatibility.Those colored pinout diagrams are nice, but limited. For real info always refer directly to the datasheet and also read the documentation of the framework you are using. Beginners tutorials are nice and can help to get you started, but when anything you find on the 'net conflicts with info from another location, both the datasheet and the info provided by your framework are the references to go to. (And those can also have errors in them).

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 24, 2025, 03:37:55 am
content: I think Doctorandus_P summarized the answer well, above. I'd just like to go a bit more into detail, showing how to find out for oneself.Feel free to skip, if such long posts aren't to your liking!First of all, OP has aSparkFun Thing Plus - ESP32 WROOM (Micro-B), based on the sku WRL-15663, that uses the Espressif ESP32-D0WDQ6 microcontroller module. That SparkFun page has two links: to theHookup Guide, and to thePDF Datasheet for ESP32 WROOM 32E (v1.6). The graphical datasheet is on the second page of the hookup guide (PDF link, version 2.0). It's really just a one-page hook-up summary, not a datasheet, even though that is what SparkFun does call it.Espressif has a later version datasheet for the microcontroller module,ESP32-WROOM-32E Datasheet (v1.8) here, and the corresponding technical reference manual,ESP32 Technical Reference Manual (English) here.If we look at the datasheet,5.2.2 Serial Peripheral Interface (SPI), it tells us ESP32 has four SPI peripherals. The first one, SPI0, is reserved for external memory (the Flash chip on the SparkFun ESP32 Thing board) and shares a signal bus with master-only SPI1, with the signals prefixed with SPI in the documentation; SPI2 supports both master and slave and is prefixed in documentation with HSPI; and SPI3 also supports both master and slave and is prefixed in documentation with VSPI.The question is, why the Arduino default pin labeling is so different to the hardware? The Arduino ESP32 core variant that matches the labels isesp32thing_plus, with LED on pin 13, SPI SCK on pin 5, SPI DO/MOSI on pin 18, and SPI DI/MISO on pin 19, and matching analog pins; and although the hookup guide images mention Adafruit ESP32 Feather, I don't think this is an error.Indeed, if you readESP32 Technical Reference Manual, 4. IO MUX and GPIO matrix, you'll find out that ESP32 has an extra trick up its sleeve: a GPIO matrix, which can route bus signals (the logical pins) to almost arbitrary physical pins!You can see the possible choices in theESP32 Series Datasheet, Table 4-6. Peripheral Pin Configurations. For example, for normal SPI (HSPI and VSPI), you can pick any GPIO pins.This facility is exposed in the Arduino environment when you use e.g.Code:SPIClass *vspi = NULL;void setup(void) {vspi = new SPIClass(VSPI);vspi->begin( <SCK>, <MISO>, <MOSI>, <CS> );}perEspressif ESP32 Arduino SPIdocumentation, where<SCK>(clock),<MISO>(output),<MOSI>(input), and<CS>(chip or slave select) are the pin numbers or named pin constants (likeSCKfor the default clock pin), and-1denotes unused signal on the SPI bus.If you are programming your ESP32 Thing outside the Arduino environment, then you'll find the precise information on how to route the signals in theESP32 Technical Reference Manual, 4.2 Peripheral Input via GPIO Matrix, and4.3 Peripheral Output via GPIO Matrix.I suppose that the default Arduino pinout does not match the default hardware configuration is to maximize pin (including low-level name and physical location) compatibility across SparkFun ESP32 Things (and Adafruit ESP32 Feathers). This should tell you that the GPIO matrix is robust, and that there is no real reason to prefer an 1:1 mapping.Finally, Winbond W25Q128JVSIQ is an 8-pin chip. If you use two such chips in the same bus, so they share CLK (pin 6), DO (pin 2), and DI (pin 5), connect their VCC (pin 8) and /WP (pin 3) to 3.3V, and GND (pin 4) to GND, and pick any two GPIO pins on the ESP32 Thing for their chip selects (SS = /CS); sayp1andp2. Trick is, connectp1andp2to first chip /CS (pin 1) and /HOLD (pin 7), and to second chip /HOLD (pin 7) and /CS (pin 1), respectively. To access first flash chip, setp1low andp2high. To access second flash chip, setp2low andp1high. Normally, keep both high. This way, if you ever accidentally set both low –– so the two chips would fight which one controls MISO (and the danger is that if one tries to pull it low and the other high, they might break) –– both chips are on hold and will not respond. In the Arduino environment, I believe you can simply create two instances ofSPIClass(using the same SPI device, eitherHSPIorVSPI), with same parameters except<SS>(slave select; same as /CS = active-low chip select) namingp1for one, andp2for the other:Code:SPIClass *flash1 = NULL;SPIClass *flash2 = NULL;void setup(void) {flash1 = new SPIClass(VSPI);flash2 = new SPIClass(VSPI);flash1->begin(SCK, MISO, MOSI, <Flash 1 /CS, Flash 2 /HOLD pin number>);flash2->begin(SCK, MISO, MOSI, <Flash 1 /HOLD, Flash 2 /CS pin number>);}and then useflash1orflash2to access each chip. (I have not tested this in practice, but I did take a very quick look at the official Espressif ESP32 Arduino core, and it looks like it supports this pattern; all Arduino coresshould, but as SparkFun mentions, this core might not have all its features implemented yet.)(You could easily draw your own carrier PCB in sayEasyEDA(an easy-to-learn free online schematic and PCB editor that should work in all current browsers on all OSes), with two seven-pin connectors; and another small plug-in board with the mating connector and the Flash chip, plus maybe a 100nF capacitor between the VCC and GND on the flash chip. Proper PCB designers would probably add cheap ESD diodes on the CLK, DO, DI, /CS, /HOLD signals, too, maybe with a 1MΩ resistor in parallel with the capacitor, perhaps even a small indicator LED, so that it would be safe to plug them in and out. The software would need to use timeouts when communicating with the Flash chip, to detect when one is not present.)I'd like to point out that although many other microcontrollers have similar per-pin peripheral selection, and some even roughly similar pin remapping features, some microcontrollers are completely different. For example, I like the cheap 8051- and RISC-V -based WCH microcontrollers (CH55xfamily, CH32Vxxxfamily), where you enable/disable entire peripherals, selecting from a few different pin options; for example. Thus, looking at the manufacturer microcontroller datasheet and technical reference manual, even cursorily through to find the mentions of pin multiplexing and pin matrix functionality, is very important. You do not want toassumeyou have wide latitude in selecting which pins to use, and later find out otherwise. With ESP32, most of the peripherals can be mapped to any GPIO pins, which isvery nice; just do not expect that it is generally true.