8 Replies Latest reply on Nov 17, 2016 5:16 AM by userc_38736

    looking for UART example

      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?



        • 1. Re: looking for UART example

          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.





          • 2. Re: looking for UART example

            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.






            • 3. Re: looking for UART example

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





              • 4. Re: looking for UART example

                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. 







                • 5. Re: looking for UART example

                  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

                  • 6. Re: looking for UART example

                    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?



                    • 7. Re: looking for UART example

                      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

                      • 8. Re: looking for UART example

                        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!