I'm having a great deal of trouble getting the SPISlave example for ESP8266 on Arduino IDE to work with the Adafruit Feather HUZZAH ESP8266 board and a host microcontroller. I'm a newbie with SPI communication and low level hardware so I am completely lost with how to dig deeper and debug the problem.
My goal is to eventually send data quickly and consistently via SPI between a STM32F446RE master and a ESP-12S slave. But first, I simply want to get the example code working with an Arduino Due master and the HUZZAH, which features a ESP-12S embedded module.
-- HARDWARE --
Having made the following basic connections,
(DUE -> HUZZAH)
- MISO -> MISO
MOSI -> MOSI
SCK -> SCK
Pin 10 -> Pin 15 (chip select)
(the spec sheet for the HUZZAH board is here)
-- SOFTWARE --
I am uploading the "SPISlave_Test.ino" provided example to the HUZZAH and the "SPISlave_SafeMaster" example to the Arduino Due. In accordance with previous forum suggestions, I have also added the following patch to setup() in "SPISlave_Test.ino":
// Additional setting to have MISO change on falling edge
SPI1C2 |= 1 << SPIC2MISODM_S;
With the patch above, my master is receiving data correctly from the slave. However, that is not the case the other way around. More specifically:
In "SPISlave_SafeMaster.ino", the following is being sent:
void loop() {
delay(1000);
send("Are you alive?", 1);
}
The following variations (non-exclusive) are being received at the slave (as seen on Serial monitor):
Question: Are yo
Question: Are you
Question: Are
Question: A
Question: €
I tried printing both the data sent from the master and the data received at the slave in HEX.
From the master, I am sending the following 32 byte message:
41 72 65 20 79 6F 75 20 61 6C 69 76 65 3F 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
At the slave, that is not what is being received. For example for "Question: Are you", I am receiving:
41 72 65 20 79 6F 75 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 46 4C DD 64 D0 88 3C AD 19
It seems that the latter portion (an arbitrary number of 0s, followed by '46 4C DD 64 D0 88 3C AD 19') is always present. The first portion is never complete, and sometimes complete gibberish.
--
As mentioned earlier, I'm a complete newbie with this, and so I'm completely lost as to what next steps to take, particularly as it seems that this is the only example provided.
Where does the problem lie? And how can I fix it?
Any help would be greatly appreciated :)