ADC0804 and 8051 interfacing problem!

Thread Starter

hashim5003

Joined Apr 29, 2013
32
Also.
lcdcmd and lcddata needs return; in the end to return to main.
Well here is my code now:
Did I used busy flag in correct place?

Rich (BB code):
#include<reg52.h>

sfr ldata = 0x90;
sbit en = P3^5;
sbit rw = P3^6;
sbit rs = P3^7;
sbit busy = P1^7;

void delay()
{
	TMOD = 0x01;
	TH0 = 0x00;
	TL0 = 0x00;
	TR0 = 1;
	while(TF0 == 0);
	TR0 = 0;
	TF0 = 0;
}

void lcdbusy()
{
	rs = 0;
	rw = 1;
	while(busy == 1)
	{
		en = 0;
		delay();
		en = 1;
	}
}

void lcdcmd(char y)
{
	
	ldata = y;
	rs = 0;
	rw = 0;
	en = 1;
	delay();
	en = 0;
	lcdbusy();
	return;
}
void lcddata(char z)
{
	
	ldata = z;
	rs = 1;
	rw = 0;
	en = 1;
	delay();
	en = 0;
	lcdbusy();
	return;
}
	
void main()
{
	delay();
	lcdcmd(0x30);
	delay();
	lcdcmd(0x30);
	delay();
	lcdcmd(0x30);
	delay();
	lcdcmd(0x38);
	delay();
	lcdcmd(0x0E);
	delay();
	lcdcmd(0x01);
	delay();
	lcdcmd(0x06);

	lcddata('T');
	lcddata('E');
	lcddata('M');
	lcddata('P');
	while(1);
}
 

Thread Starter

hashim5003

Joined Apr 29, 2013
32
Could you provide me all the detail on what kind of tools that you've been using?

Possibly this, compiler, simulator, hardware, schematic, etc.
Well, I am using 8051 training kit with at89s52. Keil uvision v 4 is the compiler and proteus for simulation I am using.

Lcd that I am using is standard 16*2 jhd162a based on hitachi hd44780.
I can post pictures tomorrow if you want?

I was using same lcd previously and it was working fine. Dont know wth happened now. Its making me angry:mad:
 

Thread Starter

hashim5003

Joined Apr 29, 2013
32
Why the cursor keeps moving forward in lcd?
I have initialized it once.
Shouldn't it remain at the position next to the printed character?
 

AfdhalAtiffTan

Joined Nov 20, 2010
120
Somehow, I could not open your file.
My proteus file is a ".DSN" file.
Any alternative?

Also, could you use different compiler? Like the "mikroC for 8051"?
 

Thread Starter

hashim5003

Joined Apr 29, 2013
32
mikroC is throwing this error:

too many initializers on line 2
assigning to non lvalue TR0
assigning to non lvalue TR0
assigning to non lvalue TF0
?


Rich (BB code):
	TR0 = 1;
	while(TF0 == 0);
	TR0 = 0;
	TF0 = 0;
}
void lcdbusy()
{
	busy = 1;
	rs = 0;
	rw = 1;
	while(busy == 1)
		{
			en = 0;
			delay();
			en = 1;
		}
}
void lcdcmd(char y)
{
	ldata = y;
	rs = 0;
	rw = 0;
	en = 1;
	delay();
	en = 0;
	lcdbusy();
	return;
}
void lcddata(char z)
{
	ldata = z;
	rs = 1;
	rw = 0;
	en = 1;
	delay();
	en = 0;
	lcdbusy();
	return;
}
void main()
{
	delay();
	lcdcmd(0x30);
	delay();
	lcdcmd(0x30);
	delay();
	lcdcmd(0x30);
	delay();
	lcdcmd(0x38);
	delay();
	lcdcmd(0x0E);
	delay();
	lcdcmd(0x01);
	delay();
	lcdcmd(0x06);
	lcddata('T');
	lcddata('E');
	lcddata('M');
	lcddata('P');
	while(1);
}
 

AfdhalAtiffTan

Joined Nov 20, 2010
120
I'll try my best... :)

Referring to your previous code, did I get this right?:

MCU = AT89S52

Crystal = 12MHz

LCD's
DL - P1
EN - P3.5
RW - P3.6
RS - P3.7

ADC's
DL - P2
RD - P3.1
WR - P3.2
INT - P3.3
 
Last edited:

AfdhalAtiffTan

Joined Nov 20, 2010
120
one more question..
I still don't know why adc0804's internal clock pulse isn't working?
How did you know the clock is not working?

If your wiring is fine, with correct components, there is no reason for it to cease running.

Careful with solder flux residue close to the timing cap, some flux are conductive.
 

Thread Starter

hashim5003

Joined Apr 29, 2013
32
How did you know the clock is not working?

If your wiring is fine, with correct components, there is no reason for it to cease running.

Careful with solder flux residue close to the timing cap, some flux are conductive.
Because when I use the combinition of resistor(10k) and capacitor(150pF) adc doesn't work. I am using frequency generator in my university and adc works with that.
I am using breadboard curently.
 

Thread Starter

hashim5003

Joined Apr 29, 2013
32
@AfdhalAtiffTan
Sorry couldn't reply. I stopped temporarily. I don't have camera right now.
Now I am using schmitt trigger with a combinition on RC circuit to oscillate adc. It's internal isn't working.
 
Top