Connecting 16x2 LCD with TM4C123

Oct 6, 2024

Interfacing 16x2 Alphanumeric Displays with TM4C123 Microcontroller

Overview

  • Interface 16x2 LCD with TM4C123 microcontroller via TAA C Series Launchpad.
  • Display data on LCD in 8-bit mode.

Schematic Discussion

  • Previous Video: Discussed details of 16x2 LCD and its pinout.
  • Connections:
    • Pin 1 (VSS): Connect to ground.
    • Pin 2 (VDD): Connect to 3.3V.
    • Pin 3 (V0 - Contrast): Connect to a potentiometer (10kΩ) for contrast control.
      • Center terminal to VEE; one end to 3.3V; other end to ground.
    • Pin 4 (RS): Connect to PD0 (Register Select).
    • Pin 5 (RW): Connect to PD1 (Read/Write).
    • Pin 6 (Enable): Connect to PD2.
    • Data Pins (D0-D7):
      • D0 to PA7,
      • D1 to PA6,
      • D2 to PA5,
      • D3 to PB4,
      • D4 to PB5,
      • D5 to PB4,
      • D6 to PB1,
      • D7 to PB0.
    • Backlight: Connect anode to 3.3V through a 1kΩ resistor and cathode to ground.

Pinout Structure

  • RS (Register Select): PD0
  • RW (Read/Write): PD1
  • Enable: PD2
  • Data Lines: D0 to D7 connected as mentioned.

Functionality Overview

  • Data Function (LCD Data): Converts 8-bit data for the LCD.
  • Command Function (LCD Command): Sends instructions to the LCD.
  • String Function (LCD String): Sends a string to be displayed on the LCD.
  • Initialization Function (LCD Init): Initializes the LCD with specific commands.

Programming Steps

  1. Enable Clock for Ports: Enable clocks for ports A, B, D, and E using the RCGC GPIO register.
  2. Digitalize Pins: Configure pins as digital using the DEN register.
  3. Set Pins as Output: Use the DIR register to configure data and control pins as outputs.
  4. Define Functions:
    • LCD Data for writing data.
    • LCD Command for sending command bytes.
    • LCD String for printing a string.
    • LCD Initialization for setting up the display.

LCD Initialization Commands

  • 0x38: 8-bit mode, 16 columns, 2 rows.
  • 0x06: Auto increment cursor.
  • 0x0C: Cursor off, display on.
  • 0x01: Clear display.

Example Output

  • Successfully printed character 'a' at the first row, first column.
  • Printed "embedded" on the first row and "systems" on the second row of the LCD.

Contrast Adjustment

  • Adjust contrast using the 10kΩ potentiometer connected to the V0 (contrast) pin.

Conclusion

  • Overview of connections and programming for using the 16x2 LCD with the TM4C123 microcontroller successfully completed.