Microcontroller › 8051 › project on microcontroller based power factor improvent by static vars compensation › hi dear fellows,, i found a
May 20, 2011 at 12:32 pm
#6285
amjadhussain
Participant
hi dear fellows,,
i found a code of interfacing of ADC0808 with 89c51 here,this is the code
// Program to test ADC 0808. The output pins are connected to LED's. external clock is used for driving the ADC 0808.
#include<reg51.h>
sbit ale=P1^0; //address latch enable
sbit oe=P1^3; //output enable
sbit sc=P1^1; //start conversion
sbit eoc=P1^2; //end of conversion
sbit ADD_A=P1^4; // Address pins for selecting input channels.
sbit ADD_B=P1^5;
sbit ADD_C=P1^6;
sfr input_port=0x80;
sfr output_port=0xA0;
void delay(unsigned int count) // Function to provide time delay in msec.
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}
void main()
{
eoc=1;
input_port=0xFF;
ale=0;
oe=0;
sc=0;
while(1)
{
ADD_C=0; // Selecting input channel 2 using address lines
ADD_B=0;
ADD_A=1;
delay(2);
ale=1;
delay(2);
sc=1;
delay(1);
ale=0;
delay(1);
sc=0;
while(eoc==1);
while(eoc==0);
oe=1;
output_port=input_port;
delay(2);
oe=0;
}
but it working when i put it into the keil ,it gives synatax error in its last 4 to five lines ,i am very worried about my project because time is very short so please help me and check this code ,and tell me why it is not working and send me its corrected form at
best regards