You are here

looking for UART example | Cypress Semiconductor

looking for UART example

Summary: 8 Replies, Latest post by jag on 17 Nov 2016 05:16 AM PST
Verified Answers: 1
Last post
Log in to post new comments.
jag
jag's picture
User
5 posts

I'm trying to read a data stream of binary messages all tagged with a B5 62 start address (UBX) and don't follow the data sheet for isr and message address to buffer management.

Is there maybe an example I can't seem to find which covers this?

TIA

user_1377889's picture
User
9596 posts

Welcome in the forum.

Let the UART component do the isr handling. Set the UART Rx buffer size to 2-3 times of your message size, Increase the Tx buffer size accordingly.

Use GetRxBuffersize() API to see if something already received and read the data off the buffer.

Examples: Start Page -> Find Code Example select your PSoC5lp and search for UART.

If still got stuck post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

 

Bob

 

jag
jag's picture
User
5 posts

Thanks Bob,

I have a single 38 byte message on the port which repeats every second, and am outputing the captured data in CAN messages. While I see data, I don't see the message ID bytes, which are the first 4. I'm not sure why, but when I try to use GetByte, or ReadRxData my loop runs wide open, with streaming CAN messages at 2000Hz.

I can post the project, but maybe the loop is enough to identify my mistake, I set the Rx buffer to 64.

 

 

user_1377889's picture
User
9596 posts

GetRxBufferSize is a function you check for the address of that function to be non-zero. Use GetRxBufferSize()

 

Bob

jag
jag's picture
User
5 posts

I found that my missing data was really bad data due to feeding the serial line into the uart. This all cleaned up when I switched to a 3v Tx output line from the source chip.

Is it possible to help parse these messages by using the hardware detect to buffer option? They will all have the same unique B5 62 start bytes, but can have different length payloads. 

Thanks

 

ANKS's picture
Cypress Employee
89 posts

Hardware detect to buffer option will enable the hardware to detect the addressed bytes and forces an interrupt (RX - On Byte Received) to move only the data (address byte is not included) from the hardware FIFO into the data buffer defined by RX Buffer Size. Hardware does not save unaddressed bytes to the FIFO, and does not generate any interrupt for them

jag
jag's picture
User
5 posts

How does the hardware decide which bytes are unaddressed? Will it fill the buffer until full, or another address match is found? If so does it clear the buffer when a new match is found?

Thanks

ANKS's picture
Cypress Employee
89 posts

UART component never clear buffer.

User need to read all data or clear buffer by ClearRxBuffer API.

 

When the “Hardware detect to buffer” option is enabled:

1.UART will compare ADDRESS byte
2. If compare passes it will write to buffer DATA bytes until receive next ADDRESS byte.
3.Go to 1

jag
jag's picture
User
5 posts

Thanks, have it working great. Although I'm not using any id isr's, just parsing the data stream with a state engine to read the messages, which include a couple checksum bytes at the end.

The psoc is a nice unit, and the creator is great! 

Log in to post new comments.