cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

li09c_3970351
New Contributor

Hi Expert,

   I use the SCB SPI 4.0 component. it created code automatically. I just need polling read/write, but I can't find any read/write functions. does it access the fifo registers for r/w data?

pastedImage_0.png

0 Likes
1 Solution
Bob_Marlowe
Expert II

I don't know where you are searching for APIs, but a brief look into the datasheet will show up

SpiGetRxBuffersize() and SpiGetTxBuffersize() APIs which return the number of bytes in the resp. buffer.

Keep in mind:

For every bit (byte) the SPI interface gets, one bit (byte) is returned immediately. When the very first byte is sent, the interface does not "know" yet what to answer, so a dummy byte is returned which should be skipped.

SPI has no read command, so you must send dummy bytes to retrieve the information wanted.

A pitfall is the select line, which is automatically taken low when a byte is sent. When the buffer is empty it is taken high again. This can lead to interface errors when the byte sequence is not provided fast enough resulting in ss-line glitches.

Bob

View solution in original post

0 Likes
1 Reply
Bob_Marlowe
Expert II

I don't know where you are searching for APIs, but a brief look into the datasheet will show up

SpiGetRxBuffersize() and SpiGetTxBuffersize() APIs which return the number of bytes in the resp. buffer.

Keep in mind:

For every bit (byte) the SPI interface gets, one bit (byte) is returned immediately. When the very first byte is sent, the interface does not "know" yet what to answer, so a dummy byte is returned which should be skipped.

SPI has no read command, so you must send dummy bytes to retrieve the information wanted.

A pitfall is the select line, which is automatically taken low when a byte is sent. When the buffer is empty it is taken high again. This can lead to interface errors when the byte sequence is not provided fast enough resulting in ss-line glitches.

Bob

View solution in original post

0 Likes