Announcements

Equip yourself to optimize PSoc4 MCUs for Evs at the EV Webinar. Click here to register.

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

PSoC™ 4 Forum Discussions

wangjiazheng
Level 1
Level 1
First reply posted First question asked 5 sign-ins

hi friends

  i have a trouble when i am using  SPI to communicate with a fram .I would like to know why using spi communication must use a delay function after sending a byte and before reading it, if no delay function is used, there will be a shift.(0x01,0x02,0x03 will become 0x00 0x01 0x02).And the delay time is different, the shift is different

wangjiazheng_0-1674028463604.png

 

0 Likes
3 Replies
Srivastav
Moderator
Moderator
Moderator
100 replies posted 25 likes received 100 sign-ins

Hi @wangjiazheng ,

 

Can you please refer to this CE

https://www.infineon.com/dgdl/Infineon-CE220499_Interfacing_the_SPI_F-RAM_with_PSoC_4-Code%20Example... 

 

Thanks 

Kind Regards

Arpit Srivastav

0 Likes

hi 

thanks for your reply, i already konw what i want asking for at this ce

best regards

0 Likes
Roy_Liu
Moderator
Moderator
Moderator
1000 replies posted 500 solutions authored 5 questions asked

I guess the reason is you need to make sure the TX was completed -  the data was written to FRAM(by checking RX buffer status) before reading the data from FRAM. 

/* Start transfer */
SPIM_SpiUartWriteTxData((uint32) wrBuf[i]);

/* Wait for the end of the transfer. The number of transmitted data
* elements has to be equal to the number of received data elements. */
while (PACKET_SIZE != SPIM_SpiUartGetRxBufferSize());

/* Clear dummy bytes from TX buffer */
SPIM_SpiUartClearTxBuffer();


/* Read data from the RX buffer */
tmpBuffer[i] = (uint8) SPIM_SpiUartReadRxData();

 

Roy Liu
0 Likes