Download CodeVisionAVR User Manual
Transcript
CodeVisionAVR 4.8 LCD Functions 4.8.1 LCD Functions for displays with up to 2x40 characters The LCD Functions are intended for easy interfacing between C programs and alphanumeric LCD modules built with the Hitachi HD44780 chip or equivalent. The prototypes for these functions are placed in the file lcd.h, located in the ..\INC subdirectory. This file must be #include -ed before using the functions. Prior to #include -ing the lcd.h file, you must declare which microcontroller port is used for communication with the LCD module. The following LCD formats are supported in lcd.h: 1x8, 2x12, 3x12, 1x16, 2x16, 2x20, 4x20, 2x24 and 2x40 characters. Example: /* the LCD module is connected to PORTC */ #asm .equ __lcd_port=0x15 #endasm /* now you can include the LCD Functions */ #include <lcd.h> The LCD module must be connected to the port bits as follows: [LCD] [AVR Port] RS (pin4) ------ bit 0 RD (pin 5) ------ bit 1 EN (pin 6) ------ bit 2 DB4 (pin 11) --- bit 4 DB5 (pin 12) --- bit 5 DB6 (pin 13) --- bit 6 DB7 (pin 14) --- bit 7 You must also connect the LCD power supply and contrast control voltage, according to the data sheet. The low level LCD Functions are: void _lcd_ready(void) waits until the LCD module is ready to receive data. This function must be called prior to writing data to the LCD with the _lcd_write_data function. void _lcd_write_data(unsigned char data) writes the byte data to the LCD instruction register. This function may be used for modifying the LCD configuration. Example: /* enables the displaying of the cursor */ _lcd_ready(); _lcd_write_data(0xe); © 1998-2001 HP InfoTech S.R.L. Page 111