Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Lotus
#73175 Hello,

I'm porting Arduino SPI code over to the ESP8266 and there's use of digitalRead(MISO) commands which looks to me the ESP8266 HMISO pin (GPIO12) isn't responding to.

SPI.transfer(x), digitalWrite(SS,LOW) commands work but digitalRead(MISO) does not.

Here's my SPI header/setup:

#include <SPI.h>
pinMode(SS,OUTPUT);
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
SPI.begin();

Any help would be appreciated.

Thanks!
User avatar
By Lotus
#73177
tele_player wrote:Why are you trying to read the MISO pin?


Good question. I'm only porting what does work on an Arduino platform (ref: bottom of http://forum.arduino.cc/index.php?topic=428990.0)

Reading the datasheet of the SPI device under control:

The internal powerup sequence is completed when CHIP_RDYn
goes low. CHIP_RDYn is observed on the SO pin after CSn is pulled low.

If the chip has had sufficient time for the crystal oscillator to
stabilize after the power-on-reset, the SO pin
will go low immediately after taking CSn low. If
CSn is taken low before reset is completed the
SO pin will first go high, indicating that the
crystal oscillator is not stabilized, before going
low as shown in Figure 16.



As you see, the slave device gives a chip ready status on the SO port which the MCU needs to monitor. The device also does send out status bytes on the SO port so I do also need SPI read functionality.

Is the HMISO digitalRead functionality not written up for the ESP8266? Can I set that pin as a digital input or does that break SPI functionality?

I suppose I can also wire the SO port to another GPIO to be able to read this chip ready status, however this does not seem to be a good hardware design practice and a waste of a GPIO port.
User avatar
By tele_player
#73190 Interesting.

What makes you think digitalRead(MISO) isn’t working?

Since the MISO behavior of the chip is to indicate the clock is stable after reset, can you just skip checking it?