Professional Documents
Culture Documents
1
Serial Interfacing
2
Performance Measures
5
Blind Cycle Method for I/O
6
I/O Synchronization (cont’d)
7
Busy Wait Method for I/O
8
I/O Synchronization –
Interrupts
Interrupt uses hardware to cause special software execution.
With an input device, the hardware will request an interrupt when
input device has new data. The software interrupt service will read
from the input device and save in global RAM
With an output device, the hardware will request an interrupt when
the output device is idle. The software interrupt service will get data
from a global structure, and then write to device.
Sometimes we configure the hardware timer to request interrupts on
a periodic basis. The software interrupt service will perform a special
function, e.g., data acquisition system reading the ADC at a regular
rate.
Interrupt synchronization will be used in situations where the system
is fairly complex (e.g., a lot of I/O devices) or when real-time
response is important
9
I/O Synchronization (cont’d)
10
I/O Synchronization –
Periodic Polling
Periodic polling uses a clock interrupt to periodically check the
I/O status. At the time of the interrupt the software will check
the I/O status, performing actions as needed.
With an input device, a ready flag is set when the input device
has new data. At the next periodic interrupt after an input flag
is set, the software will read the data and save them in global
RAM.
With an output device, a ready flag is set when the output
device is idle. At the next periodic interrupt after an output flag
is set, the software will get data from a global structure, and
write it.
Periodic polling is used in situations that require interrupts, but
the I/O device does not support interrupt requests directly.
11
I/O Synchronization –
Direct Memory Access
DMA, or direct memory access, is an interfacing approach that
transfers data directly to/from memory.
With an input device, the hardware will request a DMA transfer when
the input device has new data. Without the software’s knowledge or
permission the DMA controller will read data from the input device
and save it in memory.
With an output device, the hardware will request a DMA transfer
when the output device is idle. The DMA controller will get data from
memory, and then write it to the device.
Sometimes we configure the hardware timer to request DMA
transfers on a periodic basis. DMA can be used to implement a high-
speed data acquisition system. DMA synchronization will be used in
situations where high bandwidth and low latency are important.
12
I/O Synchronization (cont’d)
Synchronization is needed as I/O devices are much slower than
software
Hardware exists in one of three states. The idle state is when the
device is disabled or inactive. No I/O occurs in the idle state. When
active (not idle) the hardware toggles between the busy and ready
states.
The interface includes a flag specifying busy (0) or ready (1) status.
Hardware-software synchronization revolves around this flag:
The hardware will set the flag when the hardware component is
complete.
The software can read the flag to determine if the device is busy or
ready.
The software can clear the flag, signifying the software component is
complete.
This flag serves as the hardware triggering event for an interrupt
13
I/O Synchronization (cont’d)
15
I/O Synchronization (cont’d)
17
I/O Synchronization (cont’d)
18
Universal Asynchronous Receiver
Transmitter (UART)
The UART serial port allows the microcontroller to
communicate with devices such as other computers,
printers, input sensors, and LCDs.
Serial transmission involves sending one bit at a time,
such that the data is spread out over time.
The total number of bits transmitted per second is called
the baud rate.
The reciprocal of the baud rate is the bit time, which is
the time to send one bit.
Most microcontrollers have at least one UART.
TM4C123 has 8 UARTs.
19
UART (cont’d)
Each UART will have a baud rate control register, which we
use to select the transmission rate.
Each device is capable of creating its own serial clock with
a transmission frequency approximately equal to the serial
clock in the computer with which it is communicating.
A frame is the smallest complete unit of serial transmission.
The frame includes a start bit (which is 0), 8 bits of data
(least significant bit first), and a stop bit (which is 1).
There is one start bit, and Stellaris® UA RTs allow us to
select 5 to 8 data bits and 1 or 2 stop bits.
20
UART (cont’d)
21
UART (cont’d)
The EIA574 standard uses RS232 voltage
levels and a DB9 connector.
Only TxD, RxD, and SG are required to
implement a simple bidirectional serial channel,
so the other signals are not shown.
The data terminal equipment (DTE) is the
computer or a terminal, and the data
communication equipment (DCE) is a modem
or printer.
22
UART (cont’d)
The LaunchPad sends UART0 channel through the USB cable, so
the circuit shown will not be needed. On the PC side of the cable,
the serial channel becomes a virtual COM port.
23
UART (cont’d)
The computer is classified as DTE, so its serial output is pin 3
in the EIA-574 cable, and its serial input is pin 2 in the
EIA-574 cable.
When connecting a DTE to another DTE, we use a cable with
pins 2 and 3 crossed. I.e., pin 2 on one DTE is connected to
pin 3 on the other DTE and pin 3 on one DTE is connected to
pin 2 on the other DTE.
When connecting a DTE to a DCE, then the cable passes the
signals straight across.
In all situations, the grounds are connected together using the
SG wire in the cable.
This channel is classified as full-duplex, because transmission
can occur in both directions simultaneously.
24