Communication between ESP8266 and CY8CKIT-059 via SPI

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
user_3716231
Level 4
Level 4
25 sign-ins 10 sign-ins 5 sign-ins

Project description:

1.CY8CKIT-059 is Master and ESP8266 mini d1 is Slave.

2.Master communicate with Slave via SPI per 2 seconds and each time the value increases 1.

Question:

I don't know why my slave device always receive "Master : 0".The value doesn't increase in each time.

But when I apply esp8266 as Master instead of CY8CKIT-059 which means both Master and Slave are esp8266,the slave device will receive data and the value will increase in each time.

 

 

0 Likes
9 Replies
Sidramesh_S
Moderator
Moderator
Moderator
250 sign-ins 100 replies posted 25 solutions authored

Hi @user_3716231 ,

I tried programming with your project. But I can see the value updating in the tera term for data:

Sidramesh_0-1678188346535.png

While sniffing the SPI lines, I could see the string value is increasing every iteration:

Sidramesh_2-1678188861987.png

 

Sidramesh_1-1678188847038.png

So, could you please point out where you are facing the issue of value not incrementing?

Warm regards

Sidramesh

0 Likes

When Master is  CY8CKIT-059  and Slave is ESP8266, the value printed to terminal is from Slave device show below:slave_1.JPG

When Master is  ESP8266 and Slave is also ESP8266, the value printed to terminal is from Slave device show below:slave_2.JPG

logic analyzer for SPI:logic analyzer.JPG

0 Likes

Hello.

ESP8266 code initializes SPI with a certain clock polarity and phase.  And that detail is not provided in the code.

I suspect KIT-059 SPI Master clock polarity and phase is not configured to the same as ESP8266.

Since you have a logic analyzer, capture the SPI transfer with ESP8266 Master and then capture the KIT-059 Master SPI transfer.  Now, compare the clock polarity and phase in these captures.  When you configure KIT-059 SPI Master component, make this clock match the ESP8622 Master clock polarity and phase.

Since there are only 4 combinations of SPI clock polarity and phase, you could just try each one until it works.

Also, ESP8266 is not 5V tolerant.  Do not connect KIT-059 with 5V to ESP8266 directly unless you have a logic level voltage translator chip in between them.  Or, you could also use the KIT-059 SIO pins when programed for 3.3V even when the rest of KIT-059 is powered from 5V.  You can refer to this link for a solution using SIO by user LEN:
Solved: CY8C5888LTI-LP097 with lmx2592 - Infineon Developer Community

 

0 Likes

I tried all SPI mode and also tried to change shift direction with each mode and applied a level shifter between CY8CKIT-059 and ESP8266, all of the results are not what I expected.

0 Likes

@BiBi_1928986 and @user_3716231 

Besides the 4 combinations of clock phase and polarity there is also MSB or LSB first.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

I  tried it, but the results still had no changes.

0 Likes
user_3716231
Level 4
Level 4
25 sign-ins 10 sign-ins 5 sign-ins

I finally solved this problem. The solution is set spi tx buffer size to 4 and I cannot understand why it does not work via setting tx buffer size to 32.

0 Likes

@user_3716231 ,

I'm glad to hear you got it to work.

As I indicated earlier, you have to get BOTH sides (Master and Slave) to agree with regards to data length, clock polarity, data bit order, etc.

The PSoC as the Master can be altered to match these parameters.

Hopefully the documentation of the ESP8266 can provide the Slave SPI configuration information.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
Sidramesh_S
Moderator
Moderator
Moderator
250 sign-ins 100 replies posted 25 solutions authored

Hi @user_3716231 ,

I'm also glad to hear you got it to work.

Thanks to @Len_CONSULTRON  and @BiBi_1928986  for your support.

Thanks and regards,
Sidramesh

0 Likes