Lab 5
Lab 5
NAME
REG #:
EXPERIMENT NO 5:
Universal Asynchronous Serial Interfacing (UART)
using Keypad on TIVA-C Board
Objective:
• Understanding of Universal Asynchronous Receiver/Transmitter (UART)
• How to interface Keypad with microcontroller using UART
Apparatus:
• TIVA-C-TM4C123GH6PM Board
• Kiel µVision software.
• ENERGIA IDE Software
• USB Cable
• PC
• Keypad
Theory:
The most basic method for communication with an embedded processor is asynchronous serial.
It is implemented over a symmetric pair of wires connecting two devices (referred as host and
target here, though these terms are arbitrary). Whenever the host has data to send to the
target, it does so by sending an encoded bit stream over its transmit (TX) wire. This data is
received by the target over its receive (RX) wire. The communication is similar in the opposite
direction. This simple arrangement is illustrated in Fig. 5.1. This mode of communications
is called asynchronous because the host and target share no time reference (no clock signal).
Instead, temporal properties are encoded in the bit stream by the transmitter and must be
decoded by the receiver.
A commonly used device for encoding and decoding such asynchronous bit streams is a Universal
Asynchronous Receiver/Transmitter (UART). UART is a circuit that sends parallel data
through a serial line. UARTs are frequently used in conjunction with the RS-232 standard which specifies the
electrical, mechanical, functional, and procedural characteristics of two data communication equipment.
A UART includes a transmitter and a receiver. The transmitter is essentially a special shift register that loads
data in parallel and then shifts it out bit by bit at a specific rate. The
receiver, on the other hand, shifts in data bit by bit and reassembles the data. One of the
basic encodings used for asynchronous serial communications is illustrated in Fig. 5.2. Every
character is transmitted in a frame which begins with a (low) start bit followed by eight data
bits and ends with a (high) stop bit. The data bits are encoded as high or low signals for (1) and
(0), respectively. Between frames, an idle condition is signaled by transmitting a continuous
high signal. Thus, every frame is guaranteed to begin with a high-low transition and to contain
at least one low-high transition. Alternatives to this basic frame structure include different
numbers of data bits, a parity bit following the last data bit to enable error detection,
and longer stop conditions. Fig. 5.2
There is no clock directly encoded in the signal the start transition provides the only temporal
information in the data stream. The transmitter and receiver each independently maintain
clocks running at (a multiple of) an agreed frequency commonly called the baud rate. These
two clocks are not synchronized and are not guaranteed to be exactly the same frequency,
but they must be close enough in frequency (better than 2%) to recover the data. Before the
transmission starts, the transmitter and receiver must agree on a set of parameters in advance,
which include the baud-rate (i.e., number of bits per second), the number of data bits and stop
bits, and use of parity bit. To understand how the UART’s receiver extracts encoded data, assume it has a clock
running at a multiple of the baud rate (e.g., 16x).
The output connector provides output pins for rows and columns. The first four pins from the left are rows and
the last four pins from the right are the columns. To sense the state of each pushbutton from a specific location
of a row and a column, we will use GPIO pins of TM4C123 microcontroller as digital input pins.
LAB MANUAL EE-273L MICROPROCESSOR SYSTEMS
As discussed earlier, internally a 4×4 keypad consists of a matrix of 4×4 push buttons. When a particular push
button is pressed, a particular row and column make contact with each other. In other words, pressing a push
button makes connection of one of the row lines with one of the column lines. It allows the current to pass
between this row and column. This contact or current flow will be used to detect which particular key is pressed.
To detect the pressed button or key of the keypad (4×4) with TM4C123, first, we should initialize GPIO pins
as digital input pins. Tiva Launchpad scans rows and columns to detect a pressed key according to following
steps:
• In the first step, TM4C123 microcontroller configures all the GPIO pins, which connect with rows
and columns of keypad, as input lines.
• After that Tiva Launchpad, selects a row and sets it HIGH.
• Then, it scans each of the column lines from the selected row.
If the scanned column lines are low, then no button is pressed in this row. If any of the column lines goes high,
Tiva Launchpad already knows to which row it belongs. In this way, the microcontroller finds the respective
position of the pressed key in terms of row and column. In programming, we will assign a specific character
and numeric value to each key of the keypad.
Lab TASK1:
In this task we send characters to the microcontroller unit (MCU) of the board by pressing keys on the
keyboard using UART communication. These characters are monitored on serial moniter.
CODE
LAB MANUAL EE-273L MICROPROCESSOR SYSTEMS
Task 2:
Enter a password from keyboard and compare it with internally saved password and send message of correct or
incorrect to serial monitor.
CODE:
Result &Conclusion: