TM4C123 TIVA kit with LCD”
TM4C123 TIVA kit with LCD”
Objective:
“To interface TM4C123 TIVA kit with LCD”
Apparatus required:
TM4C123 TIVA LaunchPad
16x2 LCD
Resistors (1kΩ) for contrast adjustment
Breadboard
Jumper wires
TM4C123 micro-controller
Theory:
The TM4C123 microcontroller, part of the Texas Instruments Tiva C Series, is a
versatile and widely used microcontroller for embedded systems. It is based on the ARM
Cortex-M4 architecture, making it a powerful yet energy-efficient choice for a wide range of
applications including robotics, IoT, industrial control systems, and automotive applications.
This microcontroller features a 32-bit processor capable of running at speeds up to 80 MHz
and incorporates a floating-point unit (FPU) for efficient mathematical computations. It is
equipped with a variety of peripherals, making it versatile for various embedded applications.
The interfacing process involves connecting the display to the TIVA board's GPIO
(General Purpose Input/Output) pins and writing code to control which segments light up
based on the desired output. Each segment of the SSD corresponds to a specific GPIO pin on
the TIVA board, when programming, a binary representation is used where each bit
corresponds to a segment being on (1) or off (0).
1
16x2 LCD:
A Liquid Crystal Display (LCD) is a flat-panel display technology commonly used in
embedded systems to visually represent alphanumeric characters and symbols. It operates by
controlling the alignment of liquid crystals using electrical signals to modulate light.
Enable (E):
Triggers the LCD to read the data
Read/Write (R/W):
Indicates whether data is being read from or written to the LCD
Procedure:
Circuit connections:
2
Microcontroller setup:
Code:
#include <stdint.h>
#include "tm4c123gh6pm.h"
void LCD_init(void);
int main(void) {
SYSCTL_RCGCGPIO_R |= 0x02;
GPIO_PORTB_DIR_R = 0xFF;
GPIO_PORTB_DEN_R = 0xFF;
LCD_init();
LCD_command(0x01);
LCD_data('H');
LCD_data('e');
LCD_data('l');
LCD_data('l');
LCD_data('o');
while (1);
void LCD_init(void) {
3
LCD_command(0x28);
LCD_command(0x06);
LCD_command(0x0F);
GPIO_PORTB_DATA_R |= 0x02;
delayMs(1);
GPIO_PORTB_DATA_R |= 0x02;
delayMs(1);
delayMs(2);
GPIO_PORTB_DATA_R |= 0x01;
GPIO_PORTB_DATA_R |= 0x02;
delayMs(1);
GPIO_PORTB_DATA_R |= 0x01;
GPIO_PORTB_DATA_R |= 0x02;
delayMs(1);
delayMs(2);
4
}
void delayMs(int n) {
int i, j;
Simulation:
Fig 3: Simulation
Practical implementation:
Code explanation:
1. #include <stdint.h>
Includes the standard library for fixed-width integer types, such as uint8_t and
int32_t.
Used to ensure portable and efficient code.
2. #include "tm4c123gh6pm.h"
Includes the header file specific to the TM4C123 microcontroller.
This file contains definitions for all registers and macros related to the
microcontroller.
3. LCD_init function:
5
Sends initialization commands to the LCD
0x28: Configures the LCD for 4-bit mode, 2-line display, and 5x8 font.
0x06: Sets entry mode to increment the cursor after each character.
0x0F: Turns the display on and enables a blinking cursor.
4. LCD_data function:
Sends a character to the LCD in two steps (higher nibble, then lower nibble).
Steps for each nibble:
Output the nibble to Port B.
Set RS for data mode.
Generate a high-to-low pulse on the Enable pin to latch the data.
Delay for stability.
5. delayMs(1000);
Creates a delay of 1000 milliseconds (1 second) between each digit.
This allows each digit to be visible for a second before switching to the next.
Summary:
This code interfaces a TM4C123 TIVA microcontroller with a 16x2 LCD in 4-bit
mode. It initializes GPIO Port B for LCD control, sends initialization commands to configure
the display, and uses separate functions to send commands and data. Characters are displayed
by sending their ASCII values in two nibbles (higher and lower) via GPIO. A delay function
ensures proper timing for stable operation.
Safety precautions:
Ensure all connections are made properly before powering up the Arduino to avoid
short circuits.
Use resistors in series with seven-segment displays to limit current and prevent
damage.
Conclusion:
In this experiment, we successfully interfaced a 16x2 LCD with the TM4C123 TIVA
microcontroller in 4-bit mode. By controlling GPIO pins, we sent commands and data to the
LCD to display a message. This lab demonstrated basic LCD interfacing concepts and the
importance of timing and signal control in embedded systems. Future enhancements could
include implementing more complex displays or integrating user inputs to change displayed
values dynamically. It demonstrates fundamental principles of digital electronics and
microcontroller programming.