Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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
 

It is compiling without any problem
 

Attachments

  • lcd.jpg
    lcd.jpg
    329.6 KB · Views: 69

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:

Executing: "C:\Program Files (x86)\HI-TECH Software\PICC-18\PRO\9.65\bin\picc18.exe" --pass1 "E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c" -q --chip=18F4550 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 37.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 37.16 illegal conversion between types
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 38.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 38.16 illegal conversion between types
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 40.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 40.16 illegal conversion between types
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 42.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 42.16 illegal conversion between types
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 47.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 47.16 illegal conversion between types
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 48.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 48.16 illegal conversion between types
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 50.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 50.16 illegal conversion between types
Error [255] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 52.14 not a member of the struct/union ""
Error [182] E:\Embedded Program\PIC18F4550\LCD\lcd_pic.c; 52.16 illegal conversion between types

********** Build failed! **********

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top