MQX : UART management

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX : UART management

2,889 Views
nicolasuhl
Contributor I

Hello,

I'm starting a project on a Coldfire 54418 with MQX.

I'm quite happy to use IO drivers and to avoid developping painful stuff as UART low level driver.

But at this point, I've spent some hours on the MQX document (I/O Drivers User's Guide) but I still have some questions on the UART management.

The UART can be used in "polled" and "interrupt" mode.

What is the difference between these 2 modes ?

When should the "polled" mode be used ?

Are "io_read" and "io_write" blocking functions ?

(For example, if I call _io_read, and no character has been received, is the task suspended until a character has been received on the UART?)

How does the flag IO_SERIAL_NON_BLOCKING operates ?

How exclusion works if several tasks call _io_read at the same time ?

I've seen many threads related to the UART but I still can't get a clear view on how it works.

Is there a reference document on this matter?

Thanks in advance.

Nicolas

Tags (1)
0 Kudos
Reply
1 Reply

644 Views
macl
Senior Contributor I

Hi,

Polled mode will poll the status in software to collect characters.  Interrupt mode will grab characters in an interrupt service routine when each character is received.  Interrupt mode is more efficient but may result in more task preemption when servicing the uart interrupt.

There is no control flow mechanism built into the uart driver, so if you have multiple tasks accessing the same uart it is best to use a binary semaphore or mutex to take and give up control.

Here are some details of the IO_SERIAL_NON_BLOCKING feature that I received from a colleague. 

The IO_SERIAL_NON_BLOCKING features is to have the driver returning any received data, no matter it is not the amount of data you were expecting. Let say, you tell the read to bring back 5 bytes and you have the IO_SERIAL_NON_BLOCKING features OFF, then the read will block until it gets the 5 bytes to give it back to the application.

If the IO_SERIAL_NON_BLOCKING features is ON then let’s say that in the UART buffers there are only 3 bytes of the 5 bytes requested, then the read() will return with only 3 bytes and will not block until it gets the 5 bytes. Many developers enables the IO_SERIAL_NON_BLOCKING features to avoid the tasks to get stuck for too much time.

Hope this helps.  Best of luck.

Regards,

Mac