UART Routines

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

cross mob
Anonymous
Not applicable

The only example code using the peripheral uart is the peripheral uart download example.  And that only reads and writes a single byte at a time.  I see the undocumented routines puart_synchronousRead and puart_synchronousWrite.  Can I start reading data a byte at a time until I determine the incoming message length, and then use this read routine to read the rest of the message?  Or will starting that routine reintialize the receive buffer and miss some bits if they already started?  And does this call return control to the OS until all the data bytes requested are read and placed in the specified buffer?  Same basic question for the write routine.  If I just pass the location of the start of the message buffer and length, will this routine transmit the message on the peripheral uart?

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

> Can I start reading data a byte at a time until I determine the incoming message length, and then use this read routine to read the rest of the message?

Yes, you can. The bytes received are buffered in a HW FIFO, so invoking this function will not* reinitialize the receive. Calling this with a NULL pointer for buffer will dump (parameter) length bytes from the HW FIFO.

> And does this call return control to the OS until all the data bytes requested are read and placed in the specified buffer?

This is a synchronous call and will return from the function only after (parameter) length bytes have been read if length is <= 16. Behavior is undefined if a larger length read is attempted.

> Same basic question for the write routine.  If I just pass the location of the start of the message buffer and length, will this routine transmit the message on the peripheral uart?

Yes, and this is a synchronous call too. Behavior if more than 16 bytes (or less if there are un-transmitted bytes in the FIFO already) are written is undefined. Use P_UART_TX_FIFO_IS_EMPTY() to check if the TX FIFO still has bytes.

* Edit

View solution in original post

29 Replies