ESP8266 Developer Zone The Official ESP8266 Forum 2017-05-18T13:55:57+08:00 https://bbs.espressif.com:443/feed.php?f=49&t=1923 2017-05-18T13:55:57+08:00 2017-05-18T13:55:57+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1923&p=13226#p13226 <![CDATA[When is SPI MISO sampled]]>
During an SPI conversation. I need to pause code execution after I send out a byte until the Pics MISO pin goes HIGH.

I have tried all manner of read syntax and can not seem to prove or disprove that I can read the value of this SPI data line while the SPI is active.

Can anyone tell me if this is possible and what code does this.

In an attempt to create a loop that will work without answering that question, I tried turning off the SPI, reassign pin 37 as input, loop until it goes HIGH and then turn SPI back on.

I can not even get this loop to work, any ideas?

Here is the code that should work:Code:

Statistics: Posted by Kallapser — Thu May 18, 2017 1:55 pm


]]>
2016-09-18T10:30:27+08:00 2016-09-18T10:30:27+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1923&p=9850#p9850 <![CDATA[When is SPI MISO sampled]]>
what value do you get to data_tmp? Does the value change if you connect SPI0_MISO to GND or IOVDD?

Can you provide your complete, corrected code?

Kind regards,
- Henrik

Statistics: Posted by Garrettet — Sun Sep 18, 2016 10:30 am


]]>
2016-07-04T00:25:06+08:00 2016-07-04T00:25:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1923&p=7692#p7692 <![CDATA[Re: When is SPI MISO sampled?]]>
jfollas wrote:
For the purpose of this post, I was referring to using the ESP as a master.

In a recent enhancement to the NodeMCU firmware, we added support for Mode 2 and Mode 3. The MOSI edge (master out, or when the ESP sets the bit from the master) is successfully set using the SPI_CK_OUT_EDGE. However, the MISO (master in, or when the ESP reads the bit from the slave) does not occur on the next clock edge as it is supposed to - instead, it seems to be happening at the same time/same edge as MOSI.

The test to illustrate the behavior had the slave set 0xAA on the SPI so that the data was valid for the MOSI clock edge, but cleared for the MISO clock edge. The ESP should have read in 0x00 based on the defined behavior for SPI (since the bit was 0 for MISO's edge), but instead, it read in 0xAA (because it was sampling on MOSI's edge).

https://github.com/nodemcu/nodemcu-firmware/pull/1162



does you have the same problem ( CPOL: 0 CPHA: 1 ) with the sampled MOSI on trailing edge?
viewtopic.php?f=7&p=7691#p7691

Statistics: Posted by rudi — Mon Jul 04, 2016 12:25 am


]]>
2016-06-07T01:03:24+08:00 2016-06-07T01:03:24+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1923&p=7233#p7233 <![CDATA[Re: When is SPI MISO sampled?]]>
In a recent enhancement to the NodeMCU firmware, we added support for Mode 2 and Mode 3. The MOSI edge (master out, or when the ESP sets the bit from the master) is successfully set using the SPI_CK_OUT_EDGE. However, the MISO (master in, or when the ESP reads the bit from the slave) does not occur on the next clock edge as it is supposed to - instead, it seems to be happening at the same time/same edge as MOSI.

The test to illustrate the behavior had the slave set 0xAA on the SPI so that the data was valid for the MOSI clock edge, but cleared for the MISO clock edge. The ESP should have read in 0x00 based on the defined behavior for SPI (since the bit was 0 for MISO's edge), but instead, it read in 0xAA (because it was sampling on MOSI's edge).

https://github.com/nodemcu/nodemcu-firmware/pull/1162

Statistics: Posted by jfollas — Tue Jun 07, 2016 1:03 am


]]>
2016-05-06T22:33:54+08:00 2016-05-06T22:33:54+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1923&p=6742#p6742 <![CDATA[Re: When is SPI MISO sampled?]]>
jfollas wrote:
SPI bits are supposed to be set on one clock edge and then read on the next.

https://en.wikipedia.org/wiki/Serial_Pe ... _and_phase

For example:

Mode 0 (CPOL=0, CPHA=0) sets the bit on the falling edge, and then samples on the next rising edge.
Mode 1 (CPOL=0, CPHA=1) set the bit on the rising edge, and then samples on the next falling edge.
Mode 2 (CPOL=1, CPHA=0) sets the bit on the rising edge, and then samples on the next falling edge.
Mode 3 (CPOL=1, CPHA=1) sets the bit on the falling edge, and then samples on the next rising edge.

I'm looking for clarification as to how to properly use SPI_CK_I_EDGE and SPI_CK_OUT_EDGE to control the behavior of when MISO is sampled.

Setting SPI_CK_OUT_EDGE to 1=rising edge and 0=falling edge per the above description correctly transitions the MOSI bit at the right time.

However, my guess that SPI_CK_I_EDGE controlled MISO was not accurate - the value here does not seem to have any effect of when the ESP8266 reads the MISO bit. In fact, testing shows that the ESP8266 is reading the MISO bit on the same clock edge that it uses to set MOSI.

Is there an undocumented bit that I am missing?


hi

in which mode you work, master or slave?
what you need, when do you read valid data?

you wrote MoSi, that is Master Out, Serial in, in the past that was SDI named too.
so you akt as Master to a Slave, right?

SPI_CK_I_EDGE (rising edge) and SPI_CK_OUT_EDGE (falling edge) are for your sampling the time position.
example put Data on MOSI pin if CK low, the slave read at in next comming CK high wave then ( this is a half wave after CK was low.


on rising edge:
CK low____ rising edge_/----CKhigh-----\_falling edge_______

on falling edge
CK high----falling edge-\___CKlow_____/-rising edge----------

hope this helps a little




best wishes
rudi ;-)

Statistics: Posted by rudi — Fri May 06, 2016 10:33 pm


]]>
2016-03-20T11:02:45+08:00 2016-03-20T11:02:45+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1923&p=6173#p6173 <![CDATA[When is SPI MISO sampled?]]>
https://en.wikipedia.org/wiki/Serial_Pe ... _and_phase

For example:

Mode 0 (CPOL=0, CPHA=0) sets the bit on the falling edge, and then samples on the next rising edge.
Mode 1 (CPOL=0, CPHA=1) set the bit on the rising edge, and then samples on the next falling edge.
Mode 2 (CPOL=1, CPHA=0) sets the bit on the rising edge, and then samples on the next falling edge.
Mode 3 (CPOL=1, CPHA=1) sets the bit on the falling edge, and then samples on the next rising edge.

I'm looking for clarification as to how to properly use SPI_CK_I_EDGE and SPI_CK_OUT_EDGE to control the behavior of when MISO is sampled.

Setting SPI_CK_OUT_EDGE to 1=rising edge and 0=falling edge per the above description correctly transitions the MOSI bit at the right time.

However, my guess that SPI_CK_I_EDGE controlled MISO was not accurate - the value here does not seem to have any effect of when the ESP8266 reads the MISO bit. In fact, testing shows that the ESP8266 is reading the MISO bit on the same clock edge that it uses to set MOSI.

Is there an undocumented bit that I am missing?

Statistics: Posted by jfollas — Sun Mar 20, 2016 11:02 am


]]>