0% found this document useful (0 votes)
10 views5 pages

Lab 5

Uploaded by

cood54480
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Lab 5

Uploaded by

cood54480
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LAB MANUAL EE-273L MICROPROCESSOR SYSTEMS

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.

Figure 5.1: Basic Serial Communication


LAB MANUAL EE-273L MICROPROCESSOR SYSTEMS

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

Figure 5.2: Transmission of a byte

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).

Figure 5.3: UART Data Transmission


LAB MANUAL EE-273L MICROPROCESSOR SYSTEMS

Figure 5.4: UART Data Reception

4×4 Keypad Interfacing with TM4C123 Tiva Launchpad


Keypads consist of push buttons arranged in row and column pattern. That means if we take an example of a
4×4 keypad, it will internally consist of 16 push buttons. As you know, to interface a single push button with a
TM4C123 microcontroller, we need one GPIO pin for each push button. If you don’t know how to use push
button with TM4C123 Tiva C Launchpad, you can read these posts:
That means to interface a 4×4 keypad with TM4C123, we need to use 16 GPIO pins. No that is not true.
Because using 16 GPIO pins only to interface a keypad is the wastage of Tiva Launchpad GPIO pins. To save
microcontroller pins, keypads are arranged in the form matrix of rows and columns. For instance, a 4×4
keypad is arranged into a matrix of four rows and four columns. By using this pattern, we will need only 8
GPIO pins of TM4C123 microcontroller. This is exactly the half of original required pins. Therefore, we need
four GPIO pins for rows and four for columns.

Figure 5.5: 4×4 keypad

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

Keypad internal diagram:

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.

Figure 5.6: 4×4 keypad internal structure

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:

You might also like