Why my program is not sending data in SPI Communication?

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello Every one,

   

I am making communication between Pi and PSOC.

   

What i am doing is the following:

   

My Pi is sending me a 2 bytes of data (16 bits). I am reading that data and performing a logical and operation and sending my filter data back.

   

Please find attachment and have a look on my program and give me your valuable suggestions.

   

Looking forward for your reply.

   

Regards

   

Awais

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are a bit wrong in how spi works. SPI is not a write from master, then write from slave. instead reading and writing goes in parallel.

   

For every bit master sends a bit from slave is transmitted at the same time, This usually results in

   

A dummy byte received from master as the first byte because slave does not know yet what master wants to see.

   

Master needs to send dummy bytes to receive new data from slave-

   

 

   

Bob

View solution in original post

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are a bit wrong in how spi works. SPI is not a write from master, then write from slave. instead reading and writing goes in parallel.

   

For every bit master sends a bit from slave is transmitted at the same time, This usually results in

   

A dummy byte received from master as the first byte because slave does not know yet what master wants to see.

   

Master needs to send dummy bytes to receive new data from slave-

   

 

   

Bob

0 Likes
Anonymous
Not applicable

For a situation where one part (Pi) sends data and the other (PSOC) processes it and returns results when finished, that is asynchronously, I would consider if UART communication could be the the best option.

0 Likes