looking for UART example

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

cross mob
Anonymous
Not applicable

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

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

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

0 Likes
Anonymous
Not applicable

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.

   

 

   

 

   

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

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

   

 

   

Bob

0 Likes
Anonymous
Not applicable

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

   

 

   

   

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

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

0 Likes
Anonymous
Not applicable

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

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

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

0 Likes
Anonymous
Not applicable

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! 

0 Likes