sexta-feira, janeiro 26, 2007

Driver Controlador HD44780 LCD

HD44780-based displays can be operated in either 8-bit or 4-bit modes. Apart from the data-bus, 2 or 3 control-lines are needed, namely RS (Register Select) which selects if the data written to the module should be interpreted as data or an instruction, R/W (Read/Write) which determines the data direction (this pin can be tied to GND to save an I/O-pin on the controller, but this will make it impossible to read back status from the display, so all data must be sent slow enough to live up to the worst-case delays found in the data-sheet), end finally E (Enable), which is used to make the display read the data-bus. Even with 8-bit microcontrollers, the displays are often used in 4-bit mode, since this allows the data and control connections to occupy only one I/O-port (8 bits, of which 6 or 7 are used).

When power is applied to the display, it will start in the unitialized state, which is indicated by the top line being all black, while nothing is displayed in the bottom line. If nothing shows up, this could be due to the contrast setting (the voltage applied to V0 - sometimes called Vee) being wrong. Note that some displays (extended temperature models) use a negative voltage for Vee. All the displays I have worked with use a positive Vee, so I haven't had any problems with the diagram shown below.

Now the initialization sequence needs to be sent to the module. If the R/W-line is not connected, it is important to play safe on the timing, to ensure proper initialization. Note that some of the initialization commands take much longer time for the display to process than normal instructions and data. One of the commands sent during the initialization-sequence will configure the display for either 4 or 8-bit mode. In 4-bit mode the two nibbles are sent one after another, both to DB7-DB4 on the display. I will not go into details about the initialization, but you can find much more elaborate information in various places on the net, such as here, or in the datasheet for the HD44780-controller. Note that the initialization also configures various parameters of the displays behaviour, such as if the cursor will be automatically advanced when writing a character, and if the cursor should be shown etc. When the initialization is complete, the black characters in the first line of the display should dissapear.

After initialization, an instruction can be sent to the display, in order to move the cursor to a specific position. For the 2x16 char displays I have worked with, the first line has character addresses 0x80-0x8F while the second line has 0xC0-0xCF. Note that other displays may have other configurations, but this seems to be the standard for this size display. The really big displays have two HD44780-controllers, and so have two enable-lines, controlling different parts of the display.



More Info Here

Para fazer o download do codigo em Linguagem C clique AQUI

Nenhum comentário: