SPI - MASTER

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

cross mob
Anonymous
Not applicable
        Hi All, I am using SPIM component. I want to read back the MISO data. Using logic analyzer i can see the data. But how to store that data in any variables??? please see my code for your reference. Please let me know what modification is needed. SPIM_WriteTxData(Control_Byte); SPIM_WriteTxData(0); SPIM_WriteTxData(0); while(!(SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE)){} while (SPIM_GetRxBufferSize()==0); u8RSUAdcValue1=(uint8) SPIM_ReadRxData(); //always returns the value 0. ???   
0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You have to expect 3 bytes : one as the return of sending the command byte and two bytes for the sent zeroes. Because sending and receiving runs in parallel in SPI conversions you can be sure that after the while(!(SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE)){}

   

your SPIM_GetRxBufferSize() returns 3.

   

And for heavens sake use someting like

   

#define Wait(x)

   

...

   

while (SPIM_GetRxBufferSize()==0) Wait();

   

That will be quite better readable than just a semicolon.. 

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob

   

 

   

Could you help me with the PSoC 5 LP and Arducam mini Communication device, I don't understand how to do the Inicialitacion of Protocol SPI and verify the response of arducam 

   

 

   

Thank you 

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Whenever a SPI master writes a value, it also read a value back in. So when you send the Control_Byte, the master reads a value which contains a dummy value. You need to throw this away. So only the second byte you read is valid.

0 Likes