Closed
Description
Board
ESP32-C3
Device Description
No hardware
Hardware Configuration
SCK = 0
MISO = 8
MOSI = 1
Version
latest master (checkout manually)
IDE Name
n/a
Operating System
n/a
Flash frequency
40MHz
PSRAM enabled
no
Upload speed
n/a
Description
SPI clock polarity is not affected by beginTransaction until the first write. This leads to slave device ignoring some SPI packets.
This has affected my TFT display, since clock polarity was not being changed before activating the display until the first command was sent.
The only solution was to write a dummy byte directly after beginTransaction
.
Related issue: moononournation/Arduino_GFX#433
I'm not sure if this is the expected behavior, but I would certainly expect beginTransaction
to immediately update SCK polarity that's appropriate for the selected SPI mode.
Sketch
SPI.beginTransaction(SPISettings(..., ..., SPI_MODE0)); // Set SPI mode to 0 (CPOL=0)
SPI.write(0xFF);
SPI.endTransaction();
// SCK is now LOW (SPI mode 0)
SPI.beginTransaction(SPISettings(..., ..., SPI_MODE3)); // Set SPI mode to 3 (CPOL=1)
// Problem: SCK is STILL LOW (SPI despite being in mode 3).
// If we assert device's SS signal, it will enter incosistent state
// due to SCK being low, effectively missing the first bit of the message.
SPI.endTransaction();
// SCK is still LOW...
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.