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.

abhishekdixit

Full Member level 2
Joined
Dec 30, 2011
Messages
124
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
India
Activity points
2,182
hello,
i am using MPLAB IDE with hi-tech compilers for programing of PIC18F4550 MCU. i want to make a program to write in LCD, i have made this program in 8051 and ARM MCU, but when i am using the same logic in this compiler,so i find many errors, most of the error related with defining the functions or variable, so if their any pdf or link from where i can get some examples of MPLAB IDE with hi-tech C compilers.
Thank you.
 

hello jayanth,
okk if you want to check my code so i am giving you my code
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;
	RW=0;
	LATC=a;
	EN=1;
	__delay_ms(10);
	EN=0;
}

void lcd_data1(unsigned char b)
{
	RS=1;
	RW=0;
	LATC=b;
	EN=1;
	__delay_ms(10);
	EN=0;
}
so please check my code. and give some suggestion..
Thank you
 
Last edited by a moderator:

If you use the Hitech PICC18 compiler, your code compiles fine:
Build C:\Documents and Settings\Administrator.BDG\My Documents\Projects\EDAboard\abhishekdixit\abhishekdixit for device 18F4550
Using driver C:\Program Files\HI-TECH Software\PICC-18\PRO\9.66\bin\picc18.exe

Make: The target "C:\Documents and Settings\Administrator.BDG\My Documents\Projects\EDAboard\abhishekdixit\main.p1" is up to date.
Executing: "C:\Program Files\HI-TECH Software\PICC-18\PRO\9.66\bin\picc18.exe" -oabhishekdixit.cof -mabhishekdixit.map --summary=default --output=default main.p1 --chip=18F4550 -P --runtime=default --opt=default -D__DEBUG=1 --rom=default --ram=default -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
HI-TECH C PRO for the PIC18 MCU Family V9.66
Copyright (C) 1984-2011 HI-TECH SOFTWARE
Serial number: HCPIC18P-XXXXXX
Advisory[1233] Employing 18F4550 errata work-arounds:
Advisory[1234] * Corrupted fast interrupt shadow registers

Memory Summary:
Program space used E6h ( 230) of 8000h bytes ( 0.7%)
Data space used 102h ( 258) of 7A0h bytes ( 13.2%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
ID Location space used 0h ( 0) of 8h nibbles ( 0.0%)
Configuration bits used 0h ( 0) of 7h words ( 0.0%)

Loaded C:\Documents and Settings\Administrator.BDG\My Documents\Projects\EDAboard\abhishekdixit\abhishekdixit.cof.

********** Build successful! **********

However, if you are using the more common Microchip C18 compiler, you'll need to make a few changes before compiling your code.

The Hitech C Compiler for PIC10/12/16 is not compatible with the PIC18F devices.

Please post the Build message log, like above, to determine the exact cause of the compiler error messages.


BigDog
 

Can you post the error messages you are getting. Did you select picc18.exe as your compiler while creating the project or did you select mcc18.exe?
 

hello jayanth,
when i compile my code, i found such type of error given below in picture.
pic error.jpg

please find the error and give me some solution..
Thank you

- - - Updated - - -

hello bigdogguru,
thanks for helping me, but when compiled my program so the starting two lines of your messages are the same, which you have posted me.but after this i found lots of the error, so i am just sending you the picture which i have captured when i captured at the time of error. so please see it and help to compile my program..
Thank you.pic error.jpg
 

Please cut and paste the build messages rather than post a screen shot, many of the compiler switches are not visible in the image.

You are using the correct compiler, PICC18.

Did you use the project wizard and select Hi-Tech Compiler suite?

BigDog
 

yes big dog, i select the Hi-Tech Compiler suitein project wizard.
and i am pasting my error which i am facing while compiling the message.
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! **********

please check this.
 

zip and post your mplab project files. Change these to LATCbits

Code:
#define RS PORTCbits.RC0
#define RW PORTCbits.RC1
#define EN PORTCbits.RC2
 

ok jayanth, i am sending yoy my program zip file.
 

Attachments

  • LCD.rar
    69.6 KB · Views: 96

Your code compiled succesfully. I see no signals on any pins except RA0 and MCLR in proteus. Also LATXbits.xyz is not working. Are you sure your lcd code is ok?
 

Attachments

  • compiled.jpg
    compiled.jpg
    340.7 KB · Views: 98
  • LCD v1.rar
    108.1 KB · Views: 87
Last edited:

hi jayanth,
of-course my code is ok. u know when tried to build the code which you have sent me, in which perhaps you add pic18f4550 library in my code, so when i build my program so it gives a error
Error [141] C:\Users\ABHISHEK\Desktop\lcd_pic.c; 2.20 can't open include file "p18f4550.h": No such file or directory

so may be is this problem is related with any other issue like missing of header file or etc?
because i didn't make any changes in code which you have given to me..
lcd_error.jpg

Thank you
 

Remove that include line. It is not necessary. I just used it for testing.

Edit:

See the attached file. It is working.
 

Attachments

  • LCD abhishek working.rar
    110.9 KB · Views: 97
  • lcd.jpg
    lcd.jpg
    178.3 KB · Views: 97
Last edited:
hello jayanth,
thanks for helping me, but can you please tell me, why you used these line in your code. i mean whatis purpose to use these commands
ADCON0 = 0x00;
ADCON1 = 0b00001111;
CMCON = 0x07;


Thank you
 

.... please tell me, canwhy you used these line in your code. i mean whatis purpose to use these commands

ADCON0 = 0x00;
ADCON1 = 0b00001111;
CMCON = 0x07;

The commands disable both the ADC inputs and comparators which also utilize the PORTA pins.

Reference: PIC18F2455/2550/4455/4550 Data Sheet, Section: 10.1 PORTA, TRISA and LATA Registers, Page: 113
Several PORTA pins are multiplexed with analog inputs,
the analog VREF+ and VREF- inputs and the comparator
voltage reference output. The operation of pins RA5
and RA3:RA0 as A/D converter inputs is selected by
clearing/setting the control bits in the ADCON1 register
(A/D Control Register 1).

Note: On a Power-on Reset, RA5 and RA3:RA0
are configured as analog inputs and read
as ‘0’. RA4 is configured as a digital input.

Code:
CLRF PORTA 		; Initialize PORTA by
				; clearing output
				; data latches
CLRF LATA 			; Alternate method
				; to clear output
				; data latches
MOVLW 0Fh 		; Configure A/D
MOVWF ADCON1 	; for digital inputs
MOVLW 07h 		; Configure comparators
MOVWF CMCON 		; for digital input
MOVLW 0CFh 		; Value used to
				; initialize data
				; direction
MOVWF TRISA 		; Set RA<3:0> as inputs
				; RA<5:4> as outputs

BigDog
 
hello big dog,
now i am facing a new problem in compiling the code, when i run my code then after build the code it build successfully just like that

buildfailed.png

but now when i rebuild my program, it gives lots of error like this

build success.png

due to this i am unable to run this program on proteus

buildfailed.png

so please help me, why this is happening...
Thank you.
 

hello jayanth,
yes ofcourse, i hav used your code. but still its not working..
 

hello jayanath,
i tried a simple port toggle code on my existing compiler,so its working fine. but when i try this lcd code, its gives that error which i describe in my previous post. so it means that its not fault of my compiler....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top