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.

ADC0804 and 8051 interfacing problem!

Status
Not open for further replies.

hashim5003

Junior Member level 2
Joined
Jul 21, 2013
Messages
21
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Activity points
116
I was using adc0831 and lm35 with at89s52. Now I am using adc0804 instead. I have written the code, it simulates on proteus but not running on the hardware. I am posting the code I have written. Plz mention if there is any problem.
Problem:
when I use while (intr == 1) lcd only shows black boxes. and without this statement all it shows "temp:000"

Code:
#include<reg52.h>

#define adc_input P2
#define lcd_data P1

void delay (int);
void lcdcmd (char);
void lcddata (char);
void lcd_init(void);

sbit r = P3^1;
sbit w = P3^2;
sbit rs = P3^7;
sbit rw = P3^6;
sbit e = P3^5;
sbit intr = P3^3;

void main()
{	
	signed char x, a, b, c;
	while (1)
	{
		r = 1;
		w = 0;
		delay (1);
		w = 1;
		while (intr == 1);
		r = 0;
	
		lcd_init();
	
		lcddata ('t');
		lcddata ('e');
		lcddata ('m');
		lcddata ('p');
		lcddata (':');
	
		x = adc_input / 10;
		a = x / 10;
		b = x % 10;
		c = adc_input % 10;
	
		lcddata ( a + 0x30 );
		lcddata ( b + 0x30 );
		lcddata ( c + 0x30 );
	}
}

void delay( int a )  
{
	int i,j ;
	for(i=0;i<a;i++)
		for(j=0; j<1275; j++);
}

void lcdcmd (char value)
{
	rs=0;
	lcd_data = value;
	rw=0;
	e=1;
	delay (1);
	e=0;

}

void lcd_init(void)
{
   lcdcmd(0x38);    
   lcdcmd(0x0c);    
   lcdcmd(0x06);
   lcdcmd(0x80);    
}
	

void lcddata (char value)
{
	rs=1;
	lcd_data = value;
	rw=0;
	e=1;
	delay (1);
	e=0;

}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top