LCD Interfacing ( obsolete )
//give your commnets.....plzz LCDs are commonly used as an output interface to embedded systems products like cell phone, data loggers and process control instruments. Figure bellow shows LCD controller Hitachi 44780 that provides a relatively simple interface between a processor and an LCD. Since the LCD interfacing is used in almost all our applications, a datasheet and other details are given in annexure I. Three output pins, viz., P2.0, P2.1 and P2.2 are used for controlling the LCD. The data is passed on to the LCD using port 1. The most important thing in LCD interfacing is to apply a minimum of 450 ns wide high to low pulse to the enable pin of the LCD. This is used to activate the latch of Hitachi 44780 to grab the data on the port pin at that instance. This program displays the string “We Thank Springer Publishers From Authors” on the LCD. The comments are self-explanatory. Program Source Code ********************************************************* #include <REG52.H> /∗ special function register declarations ∗/ /∗ for the intended 8051 derivative ∗/ sbit RS = P2∧0; // Control signal RESET of the LCD connected to pin P2.0 sbit RW = P2∧1; // Write (RW) Signal pin connected to pin P2.1 sbit EN = P2∧2; // Enable (EN) LCD control signal connected to pin P2.2 int i; void delay(void); // Delay function void INIT(void); // Function for the commands to Initialization of the LCD void ENABLE(void); // Function for the commands to enable the LCD void LINE(int); /∗ Function for the commands to choose the line for displaying the characters on the LCD ∗/ void LINE(int i) // start of LINE function { if (i==1) {RS=0; // first make the reset signal low RW=0; // make RW low to give commands to the LCD P1=0x80; // force cursor to beginning of the first line ENABLE(); // enable the LCD RS=1; } else { RS=0; RW=0; P1=0xC0; // force cursor to beginning of the second line ENABLE(); RS=1; } } void delay() // Invoking the delay function. {int j; for (j=0;j<10;j++) {for (i=0;i<100;i++); }} void ENABLE(void) // Invoking the enable function { EN=1; // Give high to low pulse to Enable the LCD. delay(); EN=0; delay(); } void INIT(void) // Initialization of the LCD by giving the proper commands. { RS=0; RW=0; EN=0; P1 = 0x38; // 2 lines and 5∗7 matrix LCD. ENABLE(); ENABLE(); ENABLE(); ENABLE(); P1 = 0x06; //Shift cursor to left ENABLE(); P1 = 0x0E; // Display ON, Cursor Blinking ENABLE(); P1 = 0x01; // Clear display Screen. ENABLE(); } void main (void) { char code dis[] = “We Thank Springer Publishers”; char code dis2[] = “From Authors”; // Array of characters to be display. char ∗p; // Pointer to point the data in the array. int j,x; while(1) {for (x=1;x<3;x++) { INIT(); LINE(1); // Display on the line 1 of the LCD. if (x==1) { p=&dis; // point the character address from the array “dis” where it is stored. } else { p=&dis2; // Point the Character address from the “dis2” where it is stored/ } for (j=0;j>8;j++){ P1= ∗p++; // Increment the pointer by 1. ENABLE(); } LINE(2); // Display the second array on the second line on the LCD. } } }
Visitors :60074 Org
Hits : 168149 hits
Month : 2079 Users