Description
Board
ESP32C3 super mini
Device Description
Qorvo DW1000 UWB module via SPI
Hardware Configuration
SPI running at 16Mhz
Version
v2.0.17
IDE Name
platformio
Operating System
Ubuntu
Flash frequency
no idea
PSRAM enabled
no
Upload speed
460800
Description
I noticed (often) random errors when reading from SPI when communicating with DW1000.
See attached screenshot:
Logic analyzer (PulseView) reads the value correctly (0xDC) but C3 does not (0x9C - highlighted in terminal).
Here you can see the MISO went down about 26ns after clock rise:
When I migrated the project from C3 to good old ESP32 all errors were gone.
So I prepared a test bed to find out the sampling delay (data latch-in after CLK rise).
It is a breadboard with a series of logical inverter pairs in 74AC04 package. Each inverter introduces about 4ns delay so 1 pair gives 8ns delay (detailed numbers on scope pictures). Then the signal is fed back to MISO and read by the module.
Now the results comparison for ESP32 and ESP32C3
number of inverter pairs | ESP32 read value | ESP32C3 read value | note |
---|---|---|---|
0 - SPICLK connected directly to MISO | 0xFF | 0xFF | |
1 pair | 0x00 | 0xFF | Scope 1. |
2 | 0x00 | 0xFF | |
3 | 0x00 | 0xFF | |
4 | 0x00 | 0x80 | Scope 2. |
5 | 0x7F | 0x00 | Scope 3. |
6 | 0x7F | 0x00 |
Oscilloscope pictures follow. CH1 - CLKOUT, CH2 - MISO
From this data it is obvious that ESP32 samples data less than 9ns after clock rise. 👍
ESP32C3 samples data somewhere around 27ns after clock rise which explains why the bit from the module was read as 0.
The api reference explains some settings for sampling but how can this be configured from Arduino?
Sketch
simply read from SPI at 16Mhz
Debug Message
N/A
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.