SneaKSz
Member
Hello ,
I'm having problems with including header files with C18 compiler in MPLAB. I want to include these files into a project :
I also included these header files into the project also the linker file for my PIC.
This is the main program :
the compiler gives an error when I try to execute this :
"... C18_LCD_ADC\ADCLCD.C:85:Error: syntax error " . This refers to " void initLCD();" wich is a function of lcd.h.
LCD.h code
LCD.C code
I think I"m including these files in a correct way , but I can't see the problem.
I"ve looked all over the internet to find examples of people who also included self made header files ( no library ) , but it's hard to find.
Someone can help me with this small problem , how to include header files?
Thanks in advance !!!
I'm having problems with including header files with C18 compiler in MPLAB. I want to include these files into a project :
Code:
#include "lcd.h"
#include "delay.h"
I also included these header files into the project also the linker file for my PIC.
This is the main program :
Code:
#include <p18f14k50.h>
//#include <htc.h>
//#include <pic18f1xk50.h>
#include "lcd.h"
#include "delay.h"
#pragma config CPUDIV = NOCLKDIV
#pragma config USBDIV = OFF
#pragma config FOSC = HS
#pragma config PLLEN = OFF
#pragma config FCMEN = OFF
#pragma config IESO = OFF
#pragma config PWRTEN = ON
#pragma config BOREN = ON
#pragma config BORV = 30
#pragma config WDTEN = OFF
#pragma config WDTPS = 1
#pragma config MCLRE = ON
#pragma config HFOFST = ON
#pragma config STVREN = ON
#pragma config LVP = OFF
#pragma config BBSIZ = OFF
#pragma config XINST = OFF
#pragma config CP0 = ON
#pragma config CPB = ON
#pragma config CPD = ON
#pragma config WRT1= ON
#pragma config WRTB = ON
#pragma config WRTC = ON
#pragma config WRTD = ON
#pragma config EBTRB = ON
#define LCD_PORT LATC // ;set constant LEDPORT = 'PORTB'
#define LCD_TRIS TRISC // ;set constant for TRIS register
//volatile bit LCD_RS @ (unsigned)&LATC*8+4;
//;LCD handshake lines
#define LCD_RS LATC4
#define LCD_RW LATC5
#define LCD_E LATC6
unsigned int templcd =0 ;
unsigned int ADCH; //temp store for 4 bit mode
unsigned int ADCL;
unsigned char w;
unsigned char conv;
void initLCD( );
void ADC_Init();
void ADC_Go();
//void Pulse_e();
//void LCD_Char(unsigned char);
//void LCD_Cmd(unsigned char);
//void Delay (unsigned int );
void main(void)
{
unsigned long ad_val;
float angle;
unsigned int AH=3; //0000 0011 = 384
unsigned int AL=100; //1100100
// both = 484
ad_val = AH;
ad_val = ad_val << 8 | AL;
angle = (float) ad_val * 5.0 / 1024.0;
// 2.3632?
// testings
OSCCON =62; //set internal clock to 4MHz
LCD_TRIS = 0; // set PortC all outputs
LCD_PORT = 0; //LCD_TRIS
Delay ( 100);
LATB=0x00;
templcd = 0;
ADCON1 = 0b01111111; // set as digital I/O
Delay ( 255);
void initLCD(); // [COLOR="Red"][SIZE="3"]ERROR HERE[/SIZE][/COLOR]
void ADC_Init();
while (1)
{
void ADC_Go(); // ADC values will still be displayed on the LCDHI-TECH C
Delay(255);
LCD_Cmd(1); // clear screen
ad_val = ADRESH;
ad_val = ad_val << 8 | ADRESL;
angle = (float) ad_val * 5.0 / 1024.0;
//LCD_Char(0x31);
//LCD_Char(0x32);
}
}
void ADC_Init()
{
ADCON2 = 0b10101110 ;//right justify, Frc/64 , 12Tad
ADCON1=0b00000000 ;//ADC ref = Vdd,Vss boven- en onderste venster
LATB4=1;//Set RB4 to analog (ANS10)
ADCON0 = 0b00101001 ;//AN10, ADC on
}
void ADC_Go()
{
GODONE =1 ;//Start conversion
//ADCPoll:
while(GODONE ==1); //Is conversion done?
// ; Result is complete - store 2 MSbits in
// ; RESULTHI and 8 LSbits in RESULTLO
ADCH = ADRESH;
ADCL= ADRESL;
}
the compiler gives an error when I try to execute this :
"... C18_LCD_ADC\ADCLCD.C:85:Error: syntax error " . This refers to " void initLCD();" wich is a function of lcd.h.
LCD.h code
Code:
#ifndef __LCD_H
#define __LCD_H
#include <p18f14k50.h>
void initLCD();
void LCD_Cmd (unsigned char w );
void Pulse_e();
void LCD_Char (unsigned char val);
#endif
LCD.C code
Code:
#ifndef __LCD_C
#define __LCD_C
//#include <pic18f1xk50.h>
#include "C18_LCD_ADC.c"
#include "lcd.h"
#include "delay.h"
#define LCD_PORT LATC
#define LCD_PORT LATC // ;set constant LEDPORT = 'PORTB'
#define LCD_TRIS TRISC // ;set constant for TRIS register
//volatile bit LCD_RS @ (unsigned)&LATC*8+4;
//;LCD handshake lines
#define LCD_RS LATC4
#define LCD_RW LATC5
#define LCD_E LATC6
unsigned int templcd =0 ;
void initLCD()
{
//INIT FROM THE PDF
// LCD_PORTbits.LCD_RS = 1;
// BCF LCD_PORT,LCD_RS ; make the LCD ready to take ORDERS
Delay (254);
LCD_Cmd(0x33); //Set 8 bit mode
Delay(5);
LCD_Cmd(0x32); //Set 4 bit mode
Delay(5);
LCD_Cmd(0x2C);//function set 2 lines; 5*11
Delay(5);
LCD_Cmd(0x08);//display off
Delay(5);
LCD_Cmd(0x01);//display clear
Delay(5);
LCD_Cmd(0x06);// entry mode set increment , no shift
Delay(5);
LCD_Cmd(0x0F); //disp ON
Delay(5);
// call LCD_Clr ;clear display
}
void LCD_Cmd (unsigned char w){
templcd=w;
w= (templcd >> 4) | (templcd << 4); ;//send upper nibble
w=w & 0x0f ;//clear upper 4 bits of W
LCD_PORT=w;
LCD_RS=0;//RS line to 0
Pulse_e(); ;//Pulse the E line high
w=templcd ;//send lower nibble
w=w&0x0f ;//clear upper 4 bits of W
LCD_PORT=w;
LCD_RS=0 ;//RS line to 0
Pulse_e(); ;//Pulse the E line high
Delay(5);
}
void Pulse_e()
{
LCD_E=1;
Delay(5);
LCD_E=0;
Delay(5);
}
void LCD_Char ( unsigned char val)
{
templcd = val;
val=(templcd >> 4) | (templcd << 4);
val=val & 0x0f ;//clear upper 4 bits of W
LCD_PORT=val;
LCD_RS=1;//RS line to 1
Delay(5);
Pulse_e();
// second part
val=templcd ;//send lower nibble
val=val&0x0f ;//clear upper 4 bits of W
LCD_PORT=val;
LCD_RS=1 ;//RS line to 1
Delay(5);
Pulse_e();
Delay(5);
}
#endif
I think I"m including these files in a correct way , but I can't see the problem.
I"ve looked all over the internet to find examples of people who also included self made header files ( no library ) , but it's hard to find.
Someone can help me with this small problem , how to include header files?
Thanks in advance !!!
Last edited: