You are currently viewing How to interface LCD with PIC16F877A PIC Evaluation Board

How to interface LCD with PIC16F877A PIC Evaluation Board

Spread the love

The PIC16F/18F Evaluation board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through USB port.

Microchip’s PIC ( PIC16F877A), PIC16F/18F Evaluation Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.

LCD (Liquid Crystal Display)

Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. A liquid crystal display (LCD) is a flat panel display that uses the light modulating properties of liquid crystals (LCs). LCD Modules can present textual information to user.

Interfacing LCD

Fig. 1 shows how to interface the LCD to microcontroller. The 2×16 character LCD interface card with supports both modes 4-bit and 8-bit interface, and also facility to adjust contrast through trim pot. In 8-bit interface 11 lines needed to create 8-bit interface; 8 data bits (D0 – D7), three control lines, address bit (RS), read/write bit (R/W) and control signal (E).

 interfacing LCD with PIC16F877A PIC Evaluation Board

Fig. 1 Interfacing LCD to Microcontroller

Interfacing LCD with PIC16F877A

We now want to display a text in PIC16F/18F Evaluation board by using LCD module. In PIC16F/18F Evaluation board contains the LCD connections in a single header.

The PIC16F/18F Evaluation board has eleven numbers of LCD connections, connected with I/O Port lines (PORTE.0 – PORTE.3 && PORTD.0 – PORTD.7) to make LCD display.

Pin Assignment with PIC16F877A

Circuit Diagram to Interface LCD with PIC16F877A

Source Code

The Interfacing LCD with PIC16F877A program is very simple and straight forward, which display a text in 2 X 16 LCD modules. Some delay is occurring when a single command / data is executed.

C Program to display a text in LCD using PIC16F877A

//Define PIC Registers
//Define I/O Functions __CONFIG(0x3f72);
//Select HS oscillator, Enable (PWRTE,BOREN),
//Disable (CPD,CP,WDTEN,In-circuit Debugger)
#define RS RE0 //LCD Register Select
#define RW RE1 //LCD Read/Write Pin
#define EN RE2 //LCD Enable Pin
#define DATA PORTD //LCD Data Port
//LCD Data Port Direction Register
//RS,RW,EN Direction Register void lcdinit(void);
//LCD initialization Function void lcdclr(void);
//LCD Clear Function void lcdcomd(unsigned char);
//LCD Command Declaring Fucntion void lcddata(unsigned char);
//LCD Data Display Fucntion void DelayMs(unsigned int);
void main()
int i;
unsigned char First[]={" PIC DEV. BOARD "};
unsigned char Secnd[]={"LCD DEMO PROGRAM"};
DelayMs(500); lcdinit(); DelayMs(500);
//Display the Message
//Display the Message
void lcdinit(void)
int i;
unsigned char command[]={0x38,0x0c,0x06,0x01};
//LCD Command set for 8 bit Interface, 2 Lines, 5x7 Dots ADCON1 = 0x07;
//Make PORTE Pin as Digital CNTRLDIR = 0x00;
//Make LCD control port (PORTE) as output DATADIR = 0x00;
//Make LCD Data Port (PORTD) as output port for(i=0;i<4;i++)
//Send the Initialisation Commands DelayMs(5);
void lcdclr(void)
//Send LCD clear command
void lcdcomd(unsigned char cmd)
RS=0; RW=0;
//Select Command Register, R/W--write enabled EN=1;
//Enable LCD to accept commands DATA=cmd;
EN=0; DelayMs(5);
//Give a Pulse via Enable pin
void lcddata(unsigned char byte)
//Select Data register, R/W--write enabled EN=1;
//Give a Pulse via Enable pin EN=0;
void DelayMs(unsigned int Ms)
int delay_cnst; while(Ms>0)
for(delay_cnst = 0;
delay_cnst <220;delay_cnst++);

To compile the above C code you must need the Mplab software & Hi-Tech C Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without microcontroller Board.

The PICKIT2 software is used to download the hex file into your microcontroller through USB port.

Testing the LCD Module with PIC16F877A

Give +12V power supply to PIC16F/18F Evaluation board; the LCD is connected with microcontroller PIC16F/18F Evaluation board. When the program is downloading into PIC16F877A in Evaluation Board, the screen should show some text messages.

If you are not reading any text from LCD, then you just check the jumper connections and adjust the trim pot level. Otherwise you just check it with debugging mode in Mplab. If you want to see more details about debugging just see the videos in below link.

General Information

  • For proper working use the components of exact values as shown in Circuit file. Wherever possible use new components.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
  • Use the exact value crystal shown in schematic.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.