i have spnt the last few days trying to figure out what is wrong with the syntax but no luck does anyone have any suggestions? heres the code and errors it generates, my gut feeling is its realy simple
Code:
#define LCDPORT LATA
#define LCDTRIS TRISA
#define LCD_RS LATBbits.LATB4
#define LCD_TRIS_RS TRISBbits.TRISB4
#define LCD_E LATBbits.LATB1
#define LCD_TRIS_E TRISBbits.TRISB1
void Delay(int);
void WriteCommand(unsigned char);
void WriteChar(unsigned char);
void WriteNibble(unsigned char);
void WaitLCDBusy(void);
void WriteLCD(unsigned char);
void InitLCD(void);
void PutMessage(rom char*);
void PutMessageAt(unsigned char,unsigned char,rom char*);
void PutHex(unsigned char);
void PutNibble(unsigned char);
//Write a string to the LCD
void PutMessage(rom char *Message){
while(*Message!=0)
WriteChar(*Message++);
}
//Set position and write string.
void PutMessageAt(unsigned char X,unsigned char Y,rom char *Message){
WriteCommand(0x80+(--Y<<6)+--X);
while(*Message!=0)
WriteChar(*Message++);
}
void PutHex(unsigned char Num){
PutNibble(Num>>4);
PutNibble(Num&0x0f);
}
void PutNibble(unsigned char num){
if (num>9){
WriteChar(num+'A'-10);
}
else{
WriteChar(num+'0');
}
}
//Initialises the LCD
void InitLCD(void){
LCDTRIS &= 0xE1; //ensure data bits are output
LCD_E=0; //clear enable
LCD_RS = 0; //going to write command
LCD_TRIS_E=0; //Set enable to output
LCD_TRIS_RS=0; //set RS to output
Delay(30); //delay for LCD to initialise.
WriteNibble(0x30); //Required for initialisation
Delay(5); //required delay
WriteNibble(0x30); //Required for initialisation
Delay(1); //required delay
WriteCommand(0x20); //set to 4 bit interface
WriteCommand(0x2c); //set to 4 bit interface, 2 line and 5*10 font
WriteCommand(0x01); //clear display
WriteCommand(0x06); //move cursor right after write
WriteCommand(0x0C); //turn on display
}
//wait for the LCD to finish last command.
void WaitLCDBusy(void){
Delay(5);
}
//Send a command to the LCD
void WriteCommand(unsigned char command){
WaitLCDBusy(); //wait until not busy
LCD_RS = 0; //setup to send command
WriteNibble(command>>4); //write the high nibble
WriteNibble(command); //then the low nibble
}
//Send a character to the LCD
void WriteChar(unsigned char chr){
WaitLCDBusy(); //wait until not busy
LCD_RS=1; //Setup to send character
WriteNibble(chr>>4); //write the high nibble
WriteNibble(chr); //then the low nibble
}
//Send any 4 bits to the LCD
void WriteNibble(unsigned char command){
LCDPORT &= 0xE1; //clear the data bits
LCDPORT |= ((command<<1) & 0x1E); //or in the new data
LCD_E = 1; //enable the LCD interface
LCD_E = 0; //disable it
}
// delay mS at 20MHz
void Delay(int Time){
int i,j;
for(j=0;j<Time;j++)
for(i=0;i<275;i++);
}
0 1 mikroCPIC1618.exe -MSF -DBG -pP18F1320 -DL -O11111114 -fo4 -N"C:\Documents and Settings\jason\My Documents\newlcd test.mcppi" -SP"C:\Program Files\Mikroelektronika\mikroC PRO for PIC\defs\" -SP"C:\Program Files\Mikroelektronika\mikroC PRO for PIC\uses\P18\" -SP"C:\Documents and Settings\jason\My Documents\" "newlcd test.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_LcdConsts.mcl" "__Lib_Lcd.mcl"
0 125 All files Preprocessed in 40 ms
0 121 Compilation Started newlcd test.c
15 300 Syntax Error: ')' expected, but 'Chr' found newlcd test.c
16 369 Specifier needed newlcd test.c
16 300 Syntax Error: ')' expected, but 'char' found newlcd test.c
21 300 Syntax Error: ')' expected, but 'char' found newlcd test.c
24 369 Specifier needed newlcd test.c
24 394 Invalid declarator expected'(' or identifier newlcd test.c
27 369 Specifier needed newlcd test.c
27 300 Syntax Error: ')' expected, but 'char' found newlcd test.c
28 312 Internal error '' newlcd test.c
0 102 Finished (with errors): 04 Jan 2010, 15:36:53 newlcd test.mcppi