Hello eexpress,
eexpress wrote:
since 93c56 is raising CLK shift in, and falling CLK shift out, and the SPI is all raising SPSCK shift in/out current bit. it seems some critical state when MISO data shift in. or the status just like SPSCK lost the last half edge(one falling edge) at end.
I do not know how you have set up the CPOL and CPHA parameters for the SPI. However, here is where I think the problem may now lie, after close scrutiny of the EEPROM data sheet -
First, let's assume that CPOL = 0, which is consistent with the EEPROM requirement. Since the EEPROM samples DI on the positive clock edge, the setting CPHA = 0 is the appropriate setting for the sending of start bit, command bits, and address. Here, the MSB data is present at MOSI prior to the first clock edge, and changes on each negative clock edge thereafter.
However, when it comes to reading the returned data at DO (MISO), the EEPROM outputs a dummy zero bit starting near the negative clock edge of the last address bit, and then changes to the first data bit after the next positive clock edge, and each subsequent positive edge. Hence, the data should be read by the SPI on each negative clock edge. This will require that CPHA =1 (CPOL remains at zero), the opposite setting from previously.
So this situation would require the CPHA setting to be changed between the sending of address data to the EEPROM, and the reading of the returned data byte. This would only affect the READ process. I presume your existing code does not alter the setting, and I can only assume that you are actually reading the dummy byte on the first positive clock edge of the read transaction. This shows up a significant difference between Microwire and SPI.
Anyway, that is the theory - you will need to test it.
Regards,
Mac
Hello eexpress,
I think that CPOL = 0 should remain for the whole sequence to avoid any discontinuity. If you should find it necessary to disable the SPI, and then re-enable it, at the transition before reading the return bits, this should be OK provided the underlying I/O for the SPI clock pin has been previously set as an output, and for logic low. The EEPROM will wait for the next clock edge, even if it is delayed.
Regards,
Mac