LCD Interfacing PIC16F877a
LCD Interfacing PIC16F877a
LCD Interfacing PIC16F877a
THEORY :
LCD Stands for Liquid Crystal Display. It has ability to display numbers and
characters. LCDs comes in different sizes and shapes. For this project, we have selected a
16×2 character, alphanumeric LCD. It contains 2 rows of 16 character.
The LCD display has 14 pins. the function of each pin is given in table no.1
Table 1
To set cursor position at any desired position, then command is “set cursor position”.
Setting Rs to 1will tell that the data being sent is a text data. The data is loaded on the
data bus
EN line is must go from high to low for the execution of the LCD operation.
PROGRAM :
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS
oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT
disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT
disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR
disabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-
Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on
MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code
Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write
Enable bits (Write protection off; all program memory may be
written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code
Protection bit (Code protection off)
#include <xc.h>
#define en PORTEbits.RE1 //ENABLE BIT FOR LCD
#define rs PORTEbits.RE2 //REGISTER SELECT BIT FOR LCD
#define ldata PORTD //PORT FROM DATA TO BE SEND TO LCD
void delay(unsigned int);
//DELAY SUBROUTINE
void delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
CONCLUSION :
From this experiment we concluded that , programmed LED’s are vastly used for
industrial as well as commercial applications.
QUESTION :
Q. What is use of busy flag in LCD?
We use RS=0 to read the busy flag bit to see if the LCD is ready to receive information.
The busy flag is D7, and can be read when R/W=1 and RS=0,as follows: if R/W=1,RS=0.
When D7=1,the LED is busy taking care of internal operations and will not accept any new
information .When D7=0, the LCD is ready to receive new information.