Introduction
This documents the lcd library to use HD44780U-based text displays with Atmel Xmega devices. This library is based on the lcd library from Peter Fleury (http://homepage.hispeed.ch/peterfleury/) for the ATmega devices.
This library is suitable for four different io modes:
- 8 bit mode without busyflag using connections D7..D0, RS and E
- 8 bit mode with busyflag using connections D7..D0, RS, E and R/W
- 4 bit mode without busyflag using connections D7..D4, RS and E
- 4 bit mode with busyflag using connections D7..D4, RS, E and R/W
There are defines for these four modes:
- LCD_4BIT_MODE 1 is 4 nit mode, 0 is 8 bit mode
- LCD_BUSY_FLAG 1 is with busyflag, 0 is without busyflag
In 8 bit mode all 8 data pins must be connected to one 8-pin port of the Xmega. In 4 bit mode all 4 data pins must be connected to one port of Xmega, but the 4 data lines may be connected to any pin of that port and in any order. The header file lcd.h contains macro definitions that can be for that purpose.
The control lines RS, E and R/W can connected to any pin of any port of the Xmega.
- Warning
- Be careful using the busyflag. Most alfanumeric displays are 5 Volt devices. Xmega's are not 5 Volt tolerant. When using the busyflag, information is also send from the LCD to the Xmega. So you can damage your Xmega.
Setup
To use this lcd library:
-
Place lcd.c and lcd.h in your project folder.
-
Add lcd.c to your project.
-
Change lcd.h:
-
Use a global F_CPU or change in lcd.h the macro F_CPU
-
Use macro LCD_4BIT_MODE to define 4-bit mode (1) or 8-bit mode (0).
-
Use macro LCD_BUSY_FLAG to use busy flag (1) or not (0).
-
Define LCD_DATA_PORT.
-
In 4-bit mode define the pinpositions: LCD_D7_bp, LCD_D6_bp, LCD_D5_bp and LCD_D54_bp.
-
Define LCD_RS_PORT and LCD_RS_bp.
-
Define LCD_E_PORT and LCD_E_bp.
-
If you use the busyflag define in that case also LCD_RW_PORT and LCD_RW_bp.
-
Define the characrteristics of the LCD (lines, size, etc.)
Change only lcd.h, don't change lcd.c.
-
Compile lcd.c.
-
Build the complete solution.
Contact
- Author
- Wim Dolman (w.e.dolman@hva.nl)
- Version
- 1.0
Latest version can be found here: http://oege.ie.hva.nl/~dolwe/xmega/libraries/index.php
- Date
- 21-10-2013
License
This library is free software. You can redistribute it and/or modify it. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.