Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

HD44780 C Driver v3.0

Some of you might remember me posting an LCD Driver for HD44780 controller compatible displays ( *LINK* ). Well, the developing has gone forth and the new driver is smaller, faster, and easier to use! The new public released version is 3.0.
The major change is the way the LCD_Write() function works. In the previous version this function would only set the data pins and clock them in the LCD. Setting whether the data sent was going to the command register or the data register (RS pin) or whether it should read or write (RW pin), had to be done manually before each LCD_Write() call. Well, not anymore!
The new LCD_Write() function is able to properly set the RS and RW pins based on the type of data passed in the function argument. The argument has been extended to the first smallest data type higher than char (8-bit), which is the int data type (16-bit). The lower 8-bits of the parameter are the data to be sent. From the higher 8-bits only the last two bits are used to set the RS and RW pins.
Although, these changes would have brought an incompatibility issue with the previous driver which would never set the RS and RW values (they would be always 0). This is why the RS and RW values passed in the function argument are XOR masked (RS^1 and RW^0). When the RS and RW values passed are 0 or they're not passed at all (for example when passing a char argument) the XOR mask will set RS=1 and RW=0; this means the data is going to be written and it's going in the DATA register of the LCD display.
So, the new function is able to send any configuration mode for the RS and RW pins, but how to remember the proper value to give them if they are XOR-ed? Well, you don't have to worry about that because all the functions provided in the driver already have the RS and RW values preset. But, if for any reason should you need to set the RS and RW pins manually, then read the Fast LCD data type settings section in the driver header file (HD44780.h). There are some constants definitions which can be used to set the pins properly.

Because of the new way LCD_Write() works, the next functions have been deprecated: LCD_Clear(), LCD_Home(), LCD_GoTo(). They're now replaced with some macro definitions which have to be used as parameter for LCD_Write(). Macros have been defined for the LCD settings too (Function set, entry mode set ect..) to make it easier to set the LCD settings at runtime. These macros are only arithmetic operations which the compiler will convert into a number at compilation time. This results in a very lightweight way to make complex changes, by only using LCD_Write(). Usage specifics and examples have been included in the header file of the driver.

Eventually, all these changes of the driver result in way less code overhead, size and execution speed, and it's much easier to use the driver!

As usual, if you have any suggestion or if you made a porting of the driver and would like to share it, please contact me and I'll add your work to this post with the proper author credits.

The driver is released under GPL version 3 License
Make sure you read the License.txt file included in the archive or read it online here:

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <>.

You can download the driver from the attached zip file.


There are no comments to display.

Part and Inventory Search

Blog entry information

Read time
3 min read
Last update

More entries in Uncategorized

More entries from T3STY

Share this entry