Help with SPI Master Read

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

cross mob
joli_601446
Level 5
Level 5
10 likes given 10 sign-ins 5 sign-ins

Hello, I am interfacing with a 16-port GPIO expander using SPI on the PSOC5. I am using a Master SPI and am able to program the GPIO expander using the Write function of the SPI module. But know I would like to read some of the registers in the GPIO expander. I need some help with the programming for the SPI Master read. Is anyone has some examples on doing a read please share them with me.

Thank you very much,

Joe

0 Likes
1 Solution

The datasheet says the ReadRxData returns the next Byte per Word of received data.

No, the datasheet tells the value returned is a byte or a word depending on the bit setting of the SPI component which is 16 in your case.

So I sent 1 16bit word, so I will need to read the buffer twice.

You sent 2 (two) 16 bit values, this is the reason why you need to read the buffer twice

I'm not sure what to expect on the first read, it returns 0. What should I expect?

As I pointed out in my first post: When the very first byte/word is sent, the interface does not "know" yet what to answer, so a dummy byte/word is returned. This is zero (0) in your case and has no meaning.

Bob

View solution in original post

0 Likes
15 Replies