Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD programming in PIC using C

Status
Not open for further replies.

Mel_noypi

New Member
hi,

have any one know how to Program a PIC using C to be applied in LCD?? where using a PIC16f877 and a 4 line 16 chracter LCD. Im thinking of some header file for LCD to be use to simplify the program.

are their any tutorial avalable on the web that i can read or similar reference?

tenx n advnc. .

mel
 
first question: WHAT COMPILER?

as far as I know, none of the currently available C compilers are cross-compatible because they don't all conform to a standard specification, ie - ANSI C.

Therefore, without knowing what compiler you plan to use it's hard to give very useful example code.

I use BoostC, and have attached the header file that I usually use to run LCD's in 4-bit interface mode. All the I/O pins required need to be defined before the header file is included. The only built-in (proprietary) compiler functions that I make use of are the delay routines. I would expect most compilers have similar functions built-in, if not you would have to write your own. Also note that this header file is for a 2-line display. It should not take much work to modify it for a 4-line.

I would highly recommend you do some google searching and find some good info on the HD44780 LCD interfacing protocol so you actually understand what's involved in driving one. In my experience, 90% of the work in implementing an LCD interface is in getting the initialization routine working, since it requires your instruction routine works, and also requires proper data and timing between steps. After you get it initialized, the rest is easy.
 

Attachments

  • 4bitlcdinterface.h
    1.2 KB · Views: 383
Where using HI-TECH C and MPLAB v5. Are this softwares similar to yours?
I had read some tutorial on how an LCD display text on its screen. such as its instruction control codes, asci character table and on how to apply it but only manualy on a breadboard but not on C using this software. :?:
 
HiTech PICCC and MCC18 are ANSI-C, but there are "gotchas".
ANSI does not dictate the syntax of how ports are assigned. Thus one compiler might say "TRISC=0x4;" and another might say "SET_TRIS_C(0x4);" These aren't rocket science to fix.

MCC18 ended up adding "ram" and "rom" qualifiers to variable/constant declarations. This is technically an expansion on ANSI rather than a deviation, but it means code for other compilers may have trouble. It's a good idea since the architecture requires the assembly to do totally different operations for accessing ram vs rom. A function taking in a pointer to a location that could be ram or rom is logical in ANSI but bizzare to implement in PIC assembly.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top