please dont rip this site

PIC Micro Controller C Routine LCD Input / Output Library

By Andy Kunz

Character LCD Interface

LCDTEST.C is provided as a sample for the use of LCD.C, DELAY.C provides a simple delay function. All the files and a ton of related pdf's (app notes, spec sheets, etc..) are available in hitachilcd-ak.zip

The character LCD interface LCD.C/LCD.H is based upon the Hitachi LCD controller chips. In particular, I have worked almost exclusively with the Hantronix LCD products because they are priced very reasonably in small quantities, whereas other manufacturers are higher priced in small quantities. If you use another vendor, you can compare their product on a "lines and rows" basis to a similar Hantronix part and be reasonably sure it will work right-off without a problem.

LCD.C supports both the four-bit and eight-bit interface modes of the controller. Select your choice in LCD.H. Port pins for the data bus must be assigned contiguously and in order. That is, in eight-bit mode, D0 must connect to the desired I/O port’s 0 bit (say RB.0), D1 to RB.1, and so on. In four-bit mode the pins can begin anywhere in the port, but they must be sequential and contiguous. Use the definitions of LCD_D4_BIT, and LCD_TRIS_DATAMASK to match your wiring configuration. I heartily recommend using processor bits 7-4 for the data bus, and bits 3-1 for the control bus. A sample schematic is shown below:

SCHEMATIC OF 4-BIT AND 8-BIT MODES

Please note that all pins of the LCD interface except the E pin (enable) can be shared with other devices, particularly with a keypad. Any lines which are shared should be isolated from the data bus with at least 330 ohm resistors.

Be sure to set the PIN and PORT definitions in LCD.H to match your wiring configuration.

LCD.C also supports conditional exclusion of unused functions. If there are functions which you do not need in your application, you can reduce the code size by setting the appropriate LCD_ENABLE to FALSE. By default all modules are enabled. Note that some functions may be included even if you turned them off because another module requires it. Study the source to determine the exact interrelationships.

To ease the initialization of the display, LCD.C provides a startup string which is automatically configured to match your preferences as determined by the CURSOR and DISPLAY definitions. You can override these after lcd_init() by issuing the appropriate lcd_command sequence.

LCD.C also provides a few higher-level functions than what is implemented in the controller chip. These are a tiny terminal mode, whereby scrolling and some special ASCII control characters do something useful. Check function lcd_putc() to see exactly what these are.

The functions lcd_scroll() and lcd_unscroll() will scroll the LCD display up or down one line. This makes it very simple to provide your customer with a rolling display. The function lcd_define_char() enables the user to define a bit-map character for later use. When enabled, the lcd_putc() function will not perform terminal-mode functions. If you wish to have both, you will need to edit the C file to make it work the way you desire. But that’s why you have the source anyway!

Funtion lcd_printf() makes it simple to print a ROM string. This function does not perform any of the formatting commands that the C-standard printf() function peforms. If you need that level of sophistication, follow the directions in the HiTech C manual for making a user-defined character output with the printf function.

Toward the end of LCD.H you will find a few COMMAND definitions. You should use these in order to issue forward and backspace and panning commands using the function lcd_command().

To determine the current position of the cursor, use lcd_getxy(). If all you need to know is the row, the function lcd_lineof() will return it given the cursor address.

Please note that LCD.C was written to enhance speed and reduce call-stack usage, although it is possible that further enhancements by the user can provide both. The source code as provided should give a good understanding of what optimizations are or are not needed.

 

Interested:

Questions:

Comments:

See also:


file: /Techref/microchip/language/C/io/lcd/hitachilcd-ak/index.htm, 10KB, , updated: 2012/3/30 13:53, local time: 2024/12/22 12:04,
TOP NEW HELP FIND: 
3.149.240.101:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.ecomorder.com/Techref/microchip/language/C/io/lcd/hitachilcd-ak/index.htm"> Character LCD Interface</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .