Embedded Systems Building Blocks, Second Edition

11.03: Sending and Receiving Data

11.03 Sending and Receiving Data

As previously mentioned, data is sent and received by a UART by writing and reading from memory or I/O port locations. A bit in the UART's status register can be monitored to determine when a byte has been received. Similarly, another bit can be examined to see when a byte has been transmitted through the interface. This method of monitoring the UART status is called polling the I/O device and generally is used when the microprocessor can monitor the status register faster than bytes are sent and received. Polling has serious shortcomings, especially for input, because bytes can be missed while the processor is occupied with other duties. Because microprocessors have other things to do besides wait for serial I/O ports, it is common to resort to an interrupt-driven scheme to handle data reception and transmission.

11.03.01 Receiving Data

When using an interrupt-driven scheme, an interrupt is generated when a byte arrives through the serial port. The interrupt handler reads the byte from the port, which generally clears the interrupt source. At this point you have a choice of either processing the byte received in the ISR or putting the byte into some sort of buffer to let a background process handle the data. When you use a buffer, the size of the buffer depends on how quickly your background process can get control of the CPU to process the information. For example, if the worst case latency of your background...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Centronics Connectors
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.