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
Visit site
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:

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
 

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


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.
 

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.

please check this.
 

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
    340.7 KB · Views: 120
  • LCD v1.rar
    108.1 KB · Views: 114
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..


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: 118
  • lcd.jpg
    178.3 KB · Views: 118
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

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



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



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



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

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

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