Hi all,
I am relatively new to working with PIC micros. I am trying to interface a 2 line lcd display with my 18f4680 microcontroller. I am attempting to adapt code I located on the Internet to work with my PIC, however I am getting a "Syntax error" when attempting to compile it. I am using MLAB 8.46 with the C18 compiler v3.35.
My source code is below.
Any assistance would be greatly appreciated.
RePoD
I am relatively new to working with PIC micros. I am trying to interface a 2 line lcd display with my 18f4680 microcontroller. I am attempting to adapt code I located on the Internet to work with my PIC, however I am getting a "Syntax error" when attempting to compile it. I am using MLAB 8.46 with the C18 compiler v3.35.
My source code is below.
Any assistance would be greatly appreciated.
RePoD
Code:
#include <p18f4680.h>
#include <delays.h>
#define RW_PIN = PORTCbits.RC6 /* PORT for RW */
#define RS_PIN = PORTCbits.RC5 /* PORT for RS */
#define E_PIN = PORTCbits.RC7 /* PORT for E */
void prnt(unsigned int);
void commd(unsigned int);
void lcd_init(void);
void main(void)
{
int count=0;
char output[] = " Hello Daniel, ";
char output2[] = "How are you? ";
TRISC=0x00;
TRISD=0x00;
PORTC=0x00;
PORTD=0x00;
Delay10KTCYx(200);
lcd_init(); //set up LCD
while(output[count] != '\0')
{
prnt(output[count]);
count++;
}
commd(0b11000000); //Move to next line
count = 0;
while(output2[count] != '\0')
{
prnt(output2[count]); //Print character to screen
count++;
}
commd(0b10000000);
while(1)
{
}
}
void lcd_init(void)
{
E_PIN = 0;
RS_PIN = 0;
RW_PIN = 0;
commd(0b00000010); // Set cursor to Home position
commd(0b00101000); // Set to 4 bit, 2 line, 5x8 font size.
commd(0b00001100); // Set display text to on, show cursor and blink cursor to off
commd(0b00000001); // Clear Display
commd(0b00000010); // Set cursor to Home position
}
//print interface
void prnt(unsigned int character)
{
PORTD=character >> 4;
RS_PIN = 1;
E_PIN = 1;
E_PIN = 0;
RS_PIN = 0;
PORTD=character & 0x0f;
RS_PIN = 1;
E_PIN = 1;
E_PIN = 0;
RS_PIN = 0;
Delay1KTCYx(200);
}
//instruction interface
void commd(unsigned int commd)
{
PORTD=commd >> 4;
E_PIN = 1;
E_PIN = 0;
PORTD=commd &0x0f;
E_PIN = 1;
E_PIN = 0;
Delay1KTCYx(10);
}