Tuesday, September 13, 2022

LCD interface with ARM LPC2148

 


THEORY:

Liquid crystal display (LCD):

A display that consists of two polarizing transparent panels and a liquid crystal surface

sandwiched in between. An electric current passed through the liquid causes the crystal to align so that

light cannot pass through them. The LCD has ability to display numbers, characters and graphics. A

sample photo of the LCD module is shown in Figure.


LCD Pin Description:
The LCD we used in the module has 16 pins. The functions of each pin is
RS (Register select):
There are two very important registers inside the LCD
1. Command code register

2. Data register

 The RS pin is used for selection of this registers. If RS = 0, Instruction command code register is selected, allowing the user to send a command. If RS= 1 the data register is

selected, allowing the user to send data to be displayed on the LCD.

R/W (Read/ Write):

R/W input allows the user to write information to the LCD or write information from it.

R/W = 1 ; When reading

R/W = 0 ; When Writing

E (Enable):

The enable pin is used by the LCD to latch information presented to its data pins.When data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450 ns wide.

D0 – D7 (Data pins):

The 8 bit data pins, D0 – D7, are used to send information to the LCD or read the contents of the

LCD‟s internal registers.


Program code

#include <lpc214x.h> 

void  delay_ms(unsigned char time)    

{  

 unsigned int  i, j;

 for (j=0; j<time; j++)

  for(i=0; i<8002; i++);

}


void LCD_command(unsigned char command)

{

IOCLR0 = 0xFF<<16; // Clear LCD Data lines

IOCLR1=1<<16; // RS=0 for command

IOCLR1=1<<17; // RW=0 for write

IOSET0=command<<16; // put command on data line

IOSET1=(1<<18); // en=1 

delay_ms(10) ; // delay

IOCLR1=(1<<18); // en=0

}


LCD_data(unsigned char data)

{

IOCLR0 = 0xFF<<16; // Clear LCD Data lines

IOSET1=1<<16; // RS=1 for data

IOCLR1=1<<17; // RW=0 for write

IOSET0= data<<16; // put command on data line

IOSET1=(1<<18); //en=1 

delay_ms(10) ;   //delay

IOCLR1=(1<<18); //en=0

 }


LCD_init()

{

LCD_command(0x38); //8bit mode and 5x8 dotes (function set)

delay_ms(10) ; // delay

LCD_command(0x0c); //display on, cursor off, cursor char blinking off(display on/off)

delay_ms(10) ; // delay

LCD_command(0x06);  //cursor increament and display shift(entry mode set)

delay_ms(10) ; // delay

LCD_command(0x01); //clear lcd(clear command)

delay_ms(10) ; // delay

LCD_command(0x80); //set cursor to 0th location 1st lne

}

 

LCD_write_string(unsigned char *string)

{

  while(*string) //Check for End of String

  LCD_data(*string++); //sending data on LCD byte by byte

}


int main(void)

{

PINSEL1 = 0x00; //Configure PORT0 as GPIO

PINSEL2 = 0X00; //Configure PORT1 as GPIO

IODIR1= 0x07<<16; //Configure P1.18, P1.17, P1.16 as output

IODIR0= 0xFF<<16; //Configure P0.23 - P0.16 as output

LCD_init(); //Initialize LCD 16x2


LCD_write_string("Trendy Coding");

LCD_command(0xc0);//second line

LCD_write_string("Subscribe it");

while (1);

}


Circuit diagram




No comments:

Post a Comment

GPS sensor interface with ESP8266 using Blynk IoT cloud

   Circuit diagram: Source Code: #include <TinyGPS++.h> #include <SoftwareSerial.h> #define BLYNK_PRINT Serial #include <ESP8...