PIC microcontroller 16f876A interface to LCD, Need Help!!

Status
Not open for further replies.

matee

New Member
Hi, does anyone have a sample code to interface 2x16 LCD to the PIC microcontroller using PICC compiler (PCW compiler) which is using C language to program? I just need to display character to the LCD.

I found this code from the internet:

/*setup PIC Ports and Interrupts */

set_bit( STATUS, RP0 );
OPTION_REG = TxMode; // Set Option register.
set_tris_a( PortAConfig); // Setup ports
set_tris_b( PortBConfig );
clear_bit( STATUS, RP0 );
output_low_port_a( LCD_SEL ); // Disable LCD
disable_interrupt( GIE ); // Enable Global Interrupts

/* End of Setup */

When i compile it with PICC, there is an error which stated undefined STATUS.
Do you have any idea how to setup the PIC in PICC?
Thank YOU
 
Last edited:
[tentatively given advice as I haven't used C on a PIC]

If STATUS isn't defined you need to define it. It's a register name and you either need to find its address and use a #define or something so the compiler knows what it means. But this is not a completely useful answer.

It looks like you're missing a header or include file which tells the compiler all the relevent things it needs for the target chip you're using. It'll be called something like 16f877.h or possibly .inc but you'll know it when you see it.

So you'll need to insert a line like:
#include <16f877.h>
though I'm a biy hazy on the details.


I hope this helps.

(my first post here!)
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…