BluePhoenix
- Mar 6, 2016
- 1
- Joined
- Mar 6, 2016
- Messages
- 1
Hey everyone,
Recently I got into a project which requires the use of 8051. The project is mainly about interfacing 8051 with an ADC 0808 by a temperature sensor LM35. So I got a circuit and wrote the corresponding program for 8051. The trouble is, the program gets compiled in RIDE but doesn't work in the circuit when simulated using Proteus (version 7). I have attached both, the circuit diagram and the code for the 8051. Can anybody tell me what I am doing wrong and how I should correct it? Any help is very much appreciated as soon as possible.
And the corresponding code is:
#include <reg51.h>
#define input P3
sbit START=P3^0;
sbit EOC=P3^1;
sbit OE=P3^2;
sbit ADD_A = P3^3;
sbit ADD_B = P3^4;
sbit ADD_C = P3^5;
sbit ALE = P3^6;
sbit OUT1 = P0^0;
sbit OUT2 = P0^1;
sbit OUT3 = P0^2;
sbit OUT4 = P0^3;
sbit OUT5 = P0^4;
sbit OUT6 = P0^5;
sbit OUT7 = P0^6;
sbit OUT8 = P0^7;
unsigned char temp, c, i, j;
void delay()
{
for(i=0;i<1000;i++);
for(j=0;j<100;j++);
}
unsigned char adc_data (unsigned char c)
{
ADD_A=0;
ADD_B=0;
ADD_C=0;
START=1;
ALE=1;
delay();
ALE=0;
START=0;
while(EOC==1)
{
OE=1;
delay();
c=P0;
delay();
OE=0;
}
return c;
}
void main()
{
unsigned char d;
EOC=0;
ALE=0;
START=0;
ADD_A=0;
ADD_B=0;
ADD_C=0; //initial values
while(1)
{
temp=adc_data(c);
d=temp;
P1=d;
}
}
Recently I got into a project which requires the use of 8051. The project is mainly about interfacing 8051 with an ADC 0808 by a temperature sensor LM35. So I got a circuit and wrote the corresponding program for 8051. The trouble is, the program gets compiled in RIDE but doesn't work in the circuit when simulated using Proteus (version 7). I have attached both, the circuit diagram and the code for the 8051. Can anybody tell me what I am doing wrong and how I should correct it? Any help is very much appreciated as soon as possible.
And the corresponding code is:
#include <reg51.h>
#define input P3
sbit START=P3^0;
sbit EOC=P3^1;
sbit OE=P3^2;
sbit ADD_A = P3^3;
sbit ADD_B = P3^4;
sbit ADD_C = P3^5;
sbit ALE = P3^6;
sbit OUT1 = P0^0;
sbit OUT2 = P0^1;
sbit OUT3 = P0^2;
sbit OUT4 = P0^3;
sbit OUT5 = P0^4;
sbit OUT6 = P0^5;
sbit OUT7 = P0^6;
sbit OUT8 = P0^7;
unsigned char temp, c, i, j;
void delay()
{
for(i=0;i<1000;i++);
for(j=0;j<100;j++);
}
unsigned char adc_data (unsigned char c)
{
ADD_A=0;
ADD_B=0;
ADD_C=0;
START=1;
ALE=1;
delay();
ALE=0;
START=0;
while(EOC==1)
{
OE=1;
delay();
c=P0;
delay();
OE=0;
}
return c;
}
void main()
{
unsigned char d;
EOC=0;
ALE=0;
START=0;
ADD_A=0;
ADD_B=0;
ADD_C=0; //initial values
while(1)
{
temp=adc_data(c);
d=temp;
P1=d;
}
}