tag:blogger.com,1999:blog-77043402761535661422024-03-12T17:55:57.655-07:00LCD interfacing with PIC16f877APP Tradehttp://www.blogger.com/profile/10124558242124975652noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-7704340276153566142.post-4348007072644491352006-12-30T17:05:00.000-08:002009-09-02T00:09:00.621-07:00LCD interfacing with PIC16F877A<div align="justify">The purpose of this article is to give a brief tutorial on how to interface PIC16F877A with Hitachi 44780-Based LCD. </div><div align="justify"><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUdKR-GyOXh_PP3CMVxbkijYV_XzCbBovyJquWvYMPRaGK1REEbTGwql4yPUQ6xznujjeK9LdtdhodKJjA7jlbZJxu9-nt4bfbZVqbl96HLycKLwRj7R8RGvHFGmzpQ6xfjNUeg50Mw94/s1600-h/lcd.JPG"><img id="BLOGGER_PHOTO_ID_5014492113913764802" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" height="66" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUdKR-GyOXh_PP3CMVxbkijYV_XzCbBovyJquWvYMPRaGK1REEbTGwql4yPUQ6xznujjeK9LdtdhodKJjA7jlbZJxu9-nt4bfbZVqbl96HLycKLwRj7R8RGvHFGmzpQ6xfjNUeg50Mw94/s320/lcd.JPG" width="174" border="0" /></a><br /><br /><br /></div><br /><br /><div align="justify">Click here for <a href="http://www.freewebs.com/ooicp/hd44780_DATA%20SHEET.pdf">LCD data sheet</a></div><div align="justify"> </div><div align="justify"> </div><div align="justify">The most common used for the 44780-based LCD is 16 pin in a row. The pins assignment is listed in Table 1.0.<br /><br />Table 1.0 Hitachi 44780 Based LCD Pinout<br />Pin Description<br />1 Vss, Ground<br />2 Vcc, +5V supply<br />3 Vee, Contrast Voltage<br />4 R/S, Instruction / Data Mode select<br />5 R/W, Read / write<br />6 E, Enable<br />7-14 D0-D7 Data lines<br />15 +Led<br />16 -Led<br /><br />The hardware setup is shown in Figure 1.0<br /><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgua2IyQIAmuB0qo0v2GJ4PanpT9HcwMw0wPR552xJkv4Wj-EGv-HBx8AjPGTNttiIvy-gG6dAeiYUZJ5OHzZnTohWg8NE1YgjONmSI-SoySwTuPJDw5L3b2Yv3kFP3mQLZ3iAKTGueycw/s1600-h/LCD_PIC.JPG"><img id="BLOGGER_PHOTO_ID_5014493471123430354" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 281px; CURSOR: hand; HEIGHT: 181px" height="165" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgua2IyQIAmuB0qo0v2GJ4PanpT9HcwMw0wPR552xJkv4Wj-EGv-HBx8AjPGTNttiIvy-gG6dAeiYUZJ5OHzZnTohWg8NE1YgjONmSI-SoySwTuPJDw5L3b2Yv3kFP3mQLZ3iAKTGueycw/s320/LCD_PIC.JPG" width="496" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></div>Figure 1.0<br /><br />The LCD requires 3 "control" lines from the microcontroller.<br /><br /><div align="left"><strong><span style="color:#000099;">Enable (E) </span></strong></div><div align="justify">This line allows access to the display through R/W and RS lines. When this line is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks the state of the two control lines and responds accordingly. </div><div align="justify"></div><div align="left"><strong><span style="color:#000099;">Read/Write (R/W)</span></strong> </div><div align="justify">This line determines the direction of data between the LCD and microcontroller. When it is low, data is written to the LCD. When it is high, data is read from the LCD. </div><div align="justify"></div><div align="left"><strong><span style="color:#000099;">Register select (RS) </span></strong></div><div align="justify">With the help of this line, the LCD interprets the type of data on data lines. When it is low, an instruction is being written to the LCD. When it is high, a character is being written to the LCD.<br /><br />The instructions available for 44780 Hitachi LCD is shown in Table 2.0<br /><br />Table 2.0<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha59Mw1RsT6NPIj1iNsM2kQBVtgCyqcuodPjcwJKVGAL-CExLKWA9Nj_3n-XH1F_RFpwKQ4wYBNScE60GfqbPi2vzEN5RkRGn5WZ7HoMgpT_SHpi63z3PqjCY8DiZmqWF1svQjLEnOx4A/s1600-h/table2.0.JPG"><img id="BLOGGER_PHOTO_ID_5014494815448194018" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 258px; CURSOR: hand; HEIGHT: 173px" height="180" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha59Mw1RsT6NPIj1iNsM2kQBVtgCyqcuodPjcwJKVGAL-CExLKWA9Nj_3n-XH1F_RFpwKQ4wYBNScE60GfqbPi2vzEN5RkRGn5WZ7HoMgpT_SHpi63z3PqjCY8DiZmqWF1svQjLEnOx4A/s320/table2.0.JPG" width="582" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />The LCD module needs to be initialized before you can send command or data to it. The initialization steps is listed below:<br /><br />1 Wait for about 45ms delay after power is applied<br />2 Clear RS and R/W to select instruction mode and writing mode<br />3 Write the instruction set to set the interface to 8bit, 2 line and 5x7 dot<br />i.e. write b’00111011’ to LCD.<br />4 Set the Enable line then wait for 5ms for the instruction to complete.<br />5 Write the same data, b00111011 to LCD and wait >160us for instruction to complete<br />6 Write the same data again, b00111011 to LCD and wait >160us for instruction to complete<br />7 Set the operating Characteristics of the LCD<br />- Write 0x08 to turn off the display, set E = 1 for 3us<br />- Delay 50us<br />- Write 0x01 to clear the display, set E = 1 for 3us<br />- Delay 1.8ms<br />- Write 0x02 for cursor home, set E = 1 for 3us<br />- Delay 1.8ms<br />- Write 0x0F to turn on the display, set E = 1 for 3us<br />- Delay 50us<br />- Write 0x06 for entry mode set, set E = 1 for 3us<br />- Delay 50us<br />8 Set RS to 0, and R/W to 0<br /><br /><br />After the LCD initialization, now is ready to send the characters to display in the LCD. Follow the steps below to write data/character to LCD:<br /><br />1) Set RS to 1 for character mode<br />2) Clear R/W to select writing mode.<br />3) Set the character code (refer to Table 4.0) to data line.<br />4) Set E = 1 for 3us, then E = 0.<br />5) Wait for at least 160us<br />6) Repeat step 3 for the next character. </div><div align="left"><br /></div><img id="BLOGGER_PHOTO_ID_5014518558027406322" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 273px; CURSOR: hand; HEIGHT: 199px; TEXT-ALIGN: center" height="156" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidEa-mOx8H4ecAWHin3Rmhd7rIn1CSEf00degj9wVAzzzPXcI0MWT6OdGJyt76ygEHfBbNwJ0k40OtUC6zSCvGCDYaR6XLM7bMla7Q-cU0UoMY8P9pllpuULG-msmBolALQkNbb_ix7e8/s200/CGRAM.bmp" width="322" border="0" /> <div align="left">Click <a href="http://www.freewebs.com/embedded_systems/lcd_16f877a_2.asm">Here for the sample code</a>. </div>PP Tradehttp://www.blogger.com/profile/10124558242124975652noreply@blogger.com2