problem in defining function in hi-tech compiler for programing in MPLAB

Status
Not open for further replies.
ok,if you want to again see my code, so you can check this..
Code:
#include<htc.h>

#define _XTAL_FREQ 20000000

#define RS PORTEbits.RE0
#define RW PORTEbits.RE1
#define EN PORTEbits.RE2
#define LED PORTAbits.RA0

void lcd_cmd(unsigned char a);
void lcd_data1(unsigned char b);

void lcd_cmd(unsigned char a)
{
	RS=0;
	RW=0;
	LATB=a;
	EN=1;
	__delay_ms(10);
	EN=0;
}

void lcd_data1(unsigned char b)
{
	RS=1;
	RW=0;
	LATB=b;
	EN=1;
	__delay_ms(10);
	EN=0;
}

void main()
{
	unsigned char i=0;
	TRISB=0;
	LATB=0;
	TRISC=0;
	LATC=0;
	TRISA=0;
	TRISE = 0x00;
	PORTE = 0b000;
	LATB = 0b000;
	ADCON0 = 0x00;
	ADCON1 = 0b00001111;
	CMCON = 0x07;

	LED=1;

	lcd_cmd(0x38);
	__delay_ms(10);
	lcd_cmd(0x0E);
	__delay_ms(10);
	lcd_cmd(0x06);
	__delay_ms(10);
	lcd_cmd(0x01);
	__delay_ms(10);
	
	lcd_data1('A');
	lcd_data1('B');
	lcd_data1('H');
	lcd_data1('I');
	lcd_data1('S');
	lcd_data1('H');
	lcd_data1('E');
	lcd_data1('K');

		
		while(1);
	
}
please check this, and try to compile this code..
Thank you
 

yes i am using lite version of hitech-c compiler,why this may be the reason for this error...??
 

The issue appears to be related to the following #define macros:

Code:
#define RS [COLOR="#FF0000"]PORTCbits.RC0[/COLOR]
#define RW [COLOR="#FF0000"]PORTCbits.RC1[/COLOR]
#define EN [COLOR="#FF0000"]PORTCbits.RC2[/COLOR]

Particularly the predefined structure elements in red, I suspect the pic18f4550.h header file in your version of the compiler is the source of the issue.

Upload the pic18f4550.h from the include directory of your compiler, as well as the htc.h and pic18.h header files.

If you examine your code listing:

Code:
#include<htc.h>
#include<string.h>
#define _XTAL_FREQ 20000000
#define RS PORTCbits.RC0
#define RW PORTCbits.RC1
#define EN PORTCbits.RC2
#define LED RA0
void lcd_cmd(unsigned char a);
void lcd_data1(unsigned char b);
//void lcd_write(unsigned char);
//unsigned char name[]="ABHISHEK";
void main()
{
	unsigned char i=0;
	TRISB=0;
	LATB=0;
	TRISC=0;
	LATC=0;
	TRISA=0;
	lcd_cmd(0x38);
	__delay_ms(10);
	lcd_cmd(0x0E);
	__delay_ms(10);
	lcd_cmd(0x06);
	__delay_ms(10);
	lcd_cmd(0x01);
	__delay_ms(10);
	
	lcd_data1('A');
	LED=1;	
		while(1);
	
}

void lcd_cmd(unsigned char a)
{
	RS=0;	[COLOR="#FF0000"]// line 37[/COLOR]
	RW=0;	[COLOR="#FF0000"]// line 38[/COLOR]
	LATC=a;
	EN=1;	[COLOR="#FF0000"]// line 40[/COLOR]
	__delay_ms(10);
	EN=0;	[COLOR="#FF0000"]// line 42[/COLOR]
}

void lcd_data1(unsigned char b)
{
	RS=1;	[COLOR="#FF0000"]// line 47[/COLOR]
	RW=0;	[COLOR="#FF0000"]// line 48[/COLOR]
	LATC=b;
	EN=1;	[COLOR="#FF0000"]// line 50[/COLOR]
	__delay_ms(10);
	EN=0;	[COLOR="#FF0000"]// line 52[/COLOR]
}

And compare it to the build messages:


You will notice a correlation between the line number of the code listing, the build messages and your #define macros.

I suspect you have either not specified the correct device in the project wizard

Or the structure referred to in your #defined macros, PORTCbits, is not defined or defined differently in your compilers version of the pic18f4550.h device specific header file.

BigDog
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…