Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

what is the problem with this 8051 code?

Status
Not open for further replies.

Delphianrex

Junior Member level 1
Joined
Jun 30, 2010
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Iran
Activity points
1,398
hi
This code is for a Humidity Measurement circuit that i got from internet. but when i try to compile the source code with Keil C51, it gives a warning on 46th line and terminates the compilation process. but unfortunately i can't catch the problem. could anyone check the code and correct it????
The warning is on this function:

void lcd_dataa(unsigned char *disp)
{
unsigned char x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}


Thanks in advance

PHP:
// Program to Interface Humidity sensor with 8051 Microcontroller
#include<reg51.h>
sfr lcd_data_pin=0x80;//p0 port
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
sbit wr= P3^3;
sbit rd= P3^4;
sbit intr= P3^5;
sfr input_port=0x90; //p1 port
unsigned int number=0;
unsigned char humidity,lcd,key=0;
 
void delay(unsigned char count)
{
	unsigned char i;
	unsigned int j;
	for(i=0;i<count;i++)
	for(j=0;j<1275;j++);
}
 
void lcd_command(unsigned char comm)
{
	lcd_data_pin=comm;
	en=1;
	rs=0;
	rw=0;
	delay(1);
	en=0;
}
 
void lcd_data(unsigned char disp)
{
	lcd_data_pin=disp;
	en=1;
	rs=1;
	rw=0;
	delay(1);
	en=0;
}
 
void lcd_dataa(unsigned char *disp)
{
	unsigned char x;
	for(x=0;disp[x]!=0;x++)
	{
		lcd_data(disp[x]); 
	}
}
 
void lcd_ini()
{
	lcd_command(0x38);		  // for using 8-bit 2 row LCD 
	delay(50);
	lcd_command(0x0F);        // for display on cursor blinking
	delay(50);
	lcd_command(0x0C);
	delay(50);
	lcd_command(0x80);
	delay(50);	 	
}
 
void lcd_display(unsigned int val)
{  
	unsigned char flg=0;
	lcd_command(0xC7);
	if(val==0)
	lcd_data('0');
	while(val>0)
	{ 	 
		lcd=val%10;
		val=val/10;
		lcd_command(0xC7-flg);
		lcd_data(lcd+'0');
		flg++;	 
	}
	   
}
 
void display()
{
	key++;
	number=number+input_port;
	if(key==11)
	{
		number=number/key;
		number=number*10;
		number=number/25;
		humidity=number-3;
		lcd_display(humidity);
		key=0;
		number=0;
	}
}
 
void adc()
{
	rd=1;
	wr=0;
	delay(2);
	wr=1;
	while(intr==1);
	rd=0;
	display();
	delay(2);
	intr=1;
}
 
void main()
{
	lcd_ini();
	lcd_dataa("%Rel.Humidity:");
	while(1)
	{
		adc();
	}
}
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
check this... i compiled your code and got no warnings nor errors



---------- Post added at 13:56 ---------- Previous post was at 13:55 ----------

post your screen shot of the warning....
 

Delphianrex

Junior Member level 1
Joined
Jun 30, 2010
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Iran
Activity points
1,398
Thanks for your reply dear friend
I got where the problem was
 

Delphianrex

Junior Member level 1
Joined
Jun 30, 2010
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Iran
Activity points
1,398
There was a check box in the project options->Output tab->Create Hex file
This check box (create hex file) should be checked to make the output hex file.
More over it was a misinterpretation that there is a mistake with line 46. The error msg was L46 and i got that this wants to say "Line46". in fact this is the error code not the line number!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top