Download CodeVisionAVR User Manual
Transcript
CodeVisionAVR 4.8.2 LCD Functions for displays with 4x40 characters The LCD Functions are intended for easy interfacing between C programs and alphanumeric LCD modules with 4x40 characters, built with the Hitachi HD44780 chip or equivalent. The prototypes for these functions are placed in the file lcd4x40.h, located in the ..\INC subdirectory. This file must be #include -ed before using the functions. Prior to #include -ing the lcd4x40.h file, you must declare which microcontroller port is used for communication with the LCD module. Example: /* the LCD module is connected to PORTC */ #asm .equ __lcd_port=0x15 #endasm /* now you can include the LCD Functions */ #include <lcd4x40.h> The LCD module must be connected to the port bits as follows: [LCD] [AVR Port] RS (pin 11) --- bit 0 RD (pin 10) --- bit 1 EN1 (pin 9) ---- bit 2 EN2 (pin 15) -- bit 3 DB4 (pin 4) ---- bit 4 DB5 (pin 3) ---- bit 5 DB6 (pin 2) ---- bit 6 DB7 (pin 1) ---- 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. Prior calling the low level functions _lcd_ready and _lcd_write_data, the global variable _en1_msk must be set to LCD_EN1, respectively LCD_EN2, to select the upper, respectively lower half, LCD controller. © 1998-2001 HP InfoTech S.R.L. Page 114