- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @user_3716231 ,
I tried programming with your project. But I can see the value updating in the tera term for data:
While sniffing the SPI lines, I could see the string value is increasing every iteration:
So, could you please point out where you are facing the issue of value not incrementing?
Warm regards
Sidramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When Master is CY8CKIT-059 and Slave is ESP8266, the value printed to terminal is from Slave device show below:
When Master is ESP8266 and Slave is also ESP8266, the value printed to terminal is from Slave device show below:
logic analyzer for SPI:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@BiBi_1928986 and @user_3716231
Besides the 4 combinations of clock phase and polarity there is also MSB or LSB first.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried it, but the results still had no changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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