cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

Hello Every body,

   

I am doing SPI communication between Pi and PSOC 5LP.

   

I placed a command

   

while(!(SPIS_ReadTxStatus() & SPIS_STS_SPI_DONE));

   

But by doing this, my program just takes too long to fulfill the condition and when I replace the above condition with just:

   

while(!(SPIS_STS_SPI_DONE));

   

It does not!

   

I wonder why it is behaving so wierd?

   

Looking forward to your answers!

0 Likes
1 Solution
JoMe_264151
Expert II

while(!(SPIS_STS_SPI_DONE));

   

The above is testing a constant value for zero. SPIS_STS_SPI_DONE is a #defined value to check for a bit pattern. Checking with
while(!(SPIS_ReadTxStatus() & SPIS_STS_SPI_DONE));
will indeed consume MIPS. Think about to use a "callback macro". Look for that term in SPI datasheet and in Creator help.

   

 

   

Bob

View solution in original post

0 Likes
3 Replies
JoMe_264151
Expert II

while(!(SPIS_STS_SPI_DONE));

   

The above is testing a constant value for zero. SPIS_STS_SPI_DONE is a #defined value to check for a bit pattern. Checking with
while(!(SPIS_ReadTxStatus() & SPIS_STS_SPI_DONE));
will indeed consume MIPS. Think about to use a "callback macro". Look for that term in SPI datasheet and in Creator help.

   

 

   

Bob

View solution in original post

0 Likes
HeLi_263931
Honored Contributor II

while(!(SPIS_ReadTxStatus() & SPIS_STS_SPI_DONE));
will wait until the SPI communication really is finished. Yes, this will take time since it takes a while for that (depending on your SPI clock speed). There is nothing you can do about it.

   

Using a callback macro can help you to use the CPU during that time for something else (e.g. it can sleep, or calculate something else). But in any case, the time needs to be spend.

Anonymous
Not applicable

Thank you Bob and hli for your suggestions. 

   

I have a problem with buffer synchronization between pi and psoc. Any suggestion how i can over come this?

0 Likes