spi reading a byte problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

spi reading a byte problem

571 Views
harshadgami
Contributor I

Hello,

 

 

I am working with TWR-K20D72M board. I interface CAT-25256 EEPROM with this board.

my write data in eeprom is work proper.but reading data was not working.

 

when i was read data at that time if breakpoint will put then reading was sucessful. if not put breakpoint than data not read proper it gives output 0x00 .

please check my code in attachment.

It would be more appreciable if any kind of suggestions will be get.

Thanks,

Harshad

Original Attachment has been moved to: spi.txt.zip

Labels (1)
0 Kudos
3 Replies

404 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi harshad gami,

    Please give me a picture, where the breakpoint  you put will read successfully?

    It seems your my_delay is not long enough to response your reading, you can add more my_delay() to wait the external EEPROM ready.

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

404 Views
harshadgami
Contributor I

1.png2.png3.png4.png5.png

0 Kudos

404 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi harshad gami,

  1.  Did you check the communicate SPI wave?  Whether the slave return the correct data? You can use the oscilloscope check the SPI wave.

  2. check the SPI clock, whether it is in the range of your EEPROM.

  3. Use bit SPI_SR[RFDF] to wait the received data, eg

  uint8 temp;

  while(!(SPI0_SR & SPI_SR_RFDF_MASK)){}

  temp= SPI0_POPR;

SPI0_SR |= SPI_SR_RFDF_MASK;

return temp;

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos