For my project, I'm using an STM32 controller as SPI master, and an ESP8266 as SPI slave. The ESP is programmed using the Arduino ESP-SPISlave library.
Now the problem is that absolutely no data is sent or received. On the ESP side, there is not much to configure, but there is a warning in the code about SPISlave not working while SS is HIGH during startup.
On the STM32 side, however, I can configure:
Clock Polarity (CPOL): HIGH or LOW
Clock Phase (CPHA): 1 Edge or 2 Edge
Frame Format: TI or Motorola
I think I tried all combinations, without success. The ESP reference contains this sentence, but I'm unable to
translate it into STM32 settings:
The master device clock polarity configuration of ESP8266 SPI slave communication should be set with idle low power, rising edge sampling and falling edge data transformation.
Does anybody know how I need to configure the STM32 so that SPI will work?
The master device clock polarity configuration of ESP8266 SPI slave communication should be set with idle low power, rising edge sampling and falling edge data transformation.
The ESP8266 will not be looking for SPI data during the time SS is low. Starting with the time of SS rising the ESP8266 will read the incoming data. During the time of falling of the SS the data will be made available for use. The ESP32 can do duplex, as in receive data and transmit data at the same time.
You might want to get an inexpensive logic analyzer as a troubleshooting tool for SPI. I found that the HiLetgo USB Logic Analyzer does a good job for its low price.
I use ESP32's and the ESP32 SPI API, mostly because many SPI libraries do not take full advantage of the ESP32's SPI capability. I have not used a ESP8286. I recommend looking to see if the ESP266 has a SPI Slave API.
For the record, the actual cause of this problem is that the SPISlave library expects a data size of 32 bits, but for STM32s, the maximum data size is 16 bits.