SPI to SCB UART Issue

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

Hi All,

   

I am currently working to capture data from a sensor and use a PSoC 4 to transfer the bytes to my computer using SPI and the PSoC SCB UART-- I have attached my current project. Currently, when I upload and run the program, I receive constant hex values of 72 on the CoolTerm serial monitor I am using, regardless of the sensor status. All of the wiring has been configured correctly and the SPI is operating at the correct parameters, so I believe there is a fundamental problem with my coding. I am not sure, but I think I have a basic misunderstanding of transferring bytes over UART.

   

Any help or nudge in the right direction would be most welcome! Please let me know if more info is needed.

   

Thanks in Advance!

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

Welcome in the forum.

   

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.

   

There are APIs and #defined constants to check (and wait for) bytes received. Reading from SPI when nothing was received results in unknown data.

   

On UART side: your variables bx, by and er are 16 bit integers, only the lower 8 bits will be transmitted through the UART.

   


Bob

View solution in original post

0 Likes
2 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Please update your PSOC Creator to PSoC Creator  4.1 (4.1.0.2686).

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

Welcome in the forum.

   

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.

   

There are APIs and #defined constants to check (and wait for) bytes received. Reading from SPI when nothing was received results in unknown data.

   

On UART side: your variables bx, by and er are 16 bit integers, only the lower 8 bits will be transmitted through the UART.

   


Bob

0 Likes