-->
Page 1 of 2

SPI - digitalRead(MISO)

PostPosted: Tue Jan 16, 2018 11:02 am
by Lotus
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!

Re: SPI - digitalRead(MISO)

PostPosted: Tue Jan 16, 2018 11:06 am
by tele_player
Why are you trying to read the MISO pin?

Re: SPI - digitalRead(MISO)

PostPosted: Tue Jan 16, 2018 11:33 am
by Lotus
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.

Re: SPI - digitalRead(MISO)

PostPosted: Tue Jan 16, 2018 5:00 pm
by tele_player
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?