Main Menu
Home
AVR News
Atmel AVR
AVR Development Tools
Valuable Tools
WinAVR toolset
Makefile for WinAVR
AVR Virtual Simulators
Hardware for prototyping
GCC and AVR-GCC
Short introduction to C
AVR-GCC Tutorial
Example AVR Projects
AVR-GCC articles
WinAVR Site Map
Scienceprog FORUM
ScienceProg BLOG
Disclaimer
WinARM Tutorial
Login Form





Lost Password?
No account yet? Register
Latest comments
Programming AVR ADC module...
hi please send me example usart with...
More...

Measuring motor speed and...
main.c: In function...
More...

Running TX433 and RX433 RF...
(Hopefully this is not a re-post). I am...
More...

Running TX433 and RX433 RF...
I just bnought a pair of the RX/TX 433...
More...

Accessing AVR microcontroller...
You need to read PORTD 5th bit and...
More...

Syndicate
Friendly sites

Related Items:

Recommended sites


Latest News
AVR-GCC 4 bit and 8 bit LCD library PDF Print E-mail
Written by Administrator   
Wednesday, 08 August 2007
Last Updated ( Thursday, 09 August 2007 )

Standard alphanumeric LCD display controlled by 74HC164 LCD controller can accept 8 bit data bytes or 4 bit nibbles. Earlier my 4 bit and 8 bit LCD libraries were split in separate files as they were used in different projects. Now they are merged in to one library where simple logic is implemented to select 4 bit or 8 bit library just by modifying only three lines of code.

In the library header file there is line added:


//Uncomment this if LCD 4 bit interface isused

//******************************************

#define LCD_4bit

//******************************************


what allows to select different LCD modes by commenting and uncommenting this line. Also don't forget to select proper ports and pins where LCD is connected:

#define LCD_RS 0 //define MCU pin connected to LCD RS

#define LCD_RW 1 //define MCU pin connected to LCD R/W

#define LCD_E 2 //define MCU pin connected to LCD E

#define LCD_D0 0 //define MCU pin connected to LCD D0

#define LCD_D1 1 //define MCU pin connected to LCD D1

#define LCD_D2 2 //define MCU pin connected to LCD D1

#define LCD_D3 3 //define MCU pin connected to LCD D2

#define LCD_D4 4 //define MCU pin connected to LCD D3

#define LCD_D5 5 //define MCU pin connected to LCD D4

#define LCD_D6 6 //define MCU pin connected to LCD D5

#define LCD_D7 7 //define MCU pin connected to LCD D6

#define LDP PORTD //define MCU port connected to LCD data pins

#define LCP PORTD //define MCU port connected to LCD control pins

#define LDDR DDRD //define MCU direction register for port connected to LCD data pins

#define LCDR DDRD //define MCU direction register for port connected to LCD control pins


In newer library there is also couple new functionalities added:

  • Predefining 8 custom LCD characters during LCD initialisation;

  • LCDprogressBar() function have been adapted from AVRLib.


Complete function set:


void LCDsendChar(uint8_t); //forms data ready to send to 74HC164

void LCDsendCommand(uint8_t); //forms data ready to send to 74HC164

void LCDinit(void); //Initializes LCD

void LCDclr(void); //Clears LCD

void LCDhome(void); //LCD cursor home

void LCDstring(uint8_t*, uint8_t); //Outputs string to LCD

void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position

void CopyStringtoLCD(const uint8_t*, uint8_t, uint8_t);//copies flash string to LCD at x,y

void LCDdefinechar(const uint8_t *,uint8_t);//write char to LCD CGRAM

void LCDshiftRight(uint8_t); //shift by n characters Right

void LCDshiftLeft(uint8_t); //shift by n characters Left

void LCDcursorOn(void); //Underline cursor ON

void LCDcursorOnBlink(void); //Underline blinking cursor ON

void LCDcursorOFF(void); //Cursor OFF

void LCDblank(void); //LCD blank but not cleared

void LCDvisible(void); //LCD visible

void LCDcursorLeft(uint8_t); //Shift cursor left by n

void LCDcursorRight(uint8_t); //shif cursor right by n

// displays a horizontal progress bar at the current cursor location

void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length);


I have added simple demo program that should help to start working with LCD:

WinAVR 4 bit and 8 bit LCD

Download Demo Project.

Download AVR LCD Library files.



Related Items:

   

Users' Comments  
 

Average user rating

 


Add your comment
Only registered users can comment an article. Please login or register.

No comment posted



mXcomment 1.0.6 © 2007-2008 - visualclinic.fr
License Creative Commons - Some rights reserved
< Prev   Next >

© 2008 WinAVR AVR-GCC Tutorial
Joomla! is Free Software released under the GNU/GPL License.