0% found this document useful (0 votes)
15 views8 pages

Experiment4 LCD 1

The document details an experiment on interfacing a 16x2 LCD with the C8051F340 microcontroller, including the necessary program code and interfacing diagram. It outlines the functions for writing commands and data to the LCD, as well as a delay function. Additionally, it includes study questions related to the LCD's operation and functionality.

Uploaded by

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

Experiment4 LCD 1

The document details an experiment on interfacing a 16x2 LCD with the C8051F340 microcontroller, including the necessary program code and interfacing diagram. It outlines the functions for writing commands and data to the LCD, as well as a delay function. Additionally, it includes study questions related to the LCD's operation and functionality.

Uploaded by

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

S. Y. B.

Tech (ECE)
Trimester: VI Subject: MICROCONTROLLERS
Name: Krish Shah Class: A
Roll No: PA11 Batch: A2
Experiment No: 04
Name of the Experiment: Interfacing of LCD
Performed on:
Marks Teacher’s Signature with date
Submitted on:

Figure 3.1 Interfacing Diagram of 16x2 LCD with C8051F340

www.mitwpu.edu.in
Program:
/*
* LCD_Interfacing.c
*
* Created on: 09-May-2022
* Author: VK409B12
*/

#include "c8051F340.h"
void DelayMs(unsigned int Ms);
void Write_Command_Lcd(unsigned char Command);
void Write_Data_Lcd(unsigned char Character);

sbit LCD_RS = P1^5;


sbit LCD_RW = P1^6;
sbit LCD_EN = P1^7;

void main()
{
XBR1 = 0x40; /* Enable Crossbar*/
P2MDOUT = 0xFF; /* P2 output port*/
P1MDOUT = 0xE0; /* P1.5,P1.6&P1.7 output pins*/
Write_Command_Lcd(0x38); /2 Lines and 5x7 matix/
DelayMs(50); /* Delay routine*/
Write_Command_Lcd(0x01); /* Clear Display Screen*/
DelayMs(50);
Write_Command_Lcd(0X0C); /* Display ON, Cursor OFF*/
DelayMs(50);
Write_Command_Lcd(0X80); /* Force cursor to beginning of 1st line*/
DelayMs(50);
Write_Data_Lcd('W’); /* Call Data routine*/
DelayMs(50); /* Delay routine*/
Write_Data_Lcd('P’);
DelayMs(50);
Write_Data_Lcd('U');
DelayMs(50);
while (1);
}
void DelayMs(unsigned int Ms)
{
unsigned int n;

www.mitwpu.edu.in
unsigned int i;
for (n=0; n < Ms; n++)
{
for (i=0; i < 65; i++);
}
}
void Write_Command_Lcd(unsigned char Command)
{
LCD_RS = 0; //Select Command Register
LCD_RW = 0;
P2 = Command;
LCD_EN = 1; // EN pin high->low
DelayMs(15);
LCD_EN = 0;
}
void Write_Data_Lcd(unsigned char Character)
{
LCD_RS = 1; //Select Date Register
LCD_RW = 0;
P2 = Character;
LCD_EN = 1; // EN pin high->low
DelayMs(15);
LCD_EN = 0;
}

SimplicityStudio screenshots:

www.mitwpu.edu.in
www.mitwpu.edu.in
www.mitwpu.edu.in
Figure 1:Hex File

Conclusion:

Study Question:
1. Explain the 4-bit mode of LCD.
2. Explain the significance of RS pin and list commands of LCD.
3. Explain buzy flag.

www.mitwpu.edu.in
www.mitwpu.edu.in
Additional link:
1. https://www.electronicshub.org/interfacing-16x2-lcd-8051/

www.mitwpu.edu.in

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy