Vous êtes sur la page 1sur 2

ADC interfacing with 8051

Circuit Diagram:

ADC interfacing with 8051 Circuit Diagram:

Program:

#include<regx52.h>

sfr data1 = 0xA0; sfr led = 0x90;

// Port 2 is connected with D0-D7 of ADC // Port 1 is connected with LEDs

sbit cs1 = P3^0; sbit rd1 = P3^1; sbit wr1 = P3^2; sbit intr1 = P3^3;

// chip select // RD signal // WR signal // EOC signal

void delay (unsigned int x)

{

unsigned int i,j; for (i=0; i<x; i++)

{

for (j=0; j<123; j++);

}

}

void main()

{

led = 0x00;

while(1)

{

 

cs1 = 0; rd1 = 1;

delay(1);

wr1 = 0;

// SOC pulse

delay(2);

wr1 = 1;

delay(2);

while(intr1 == 1);

// wait for EOC

cs1 = 0; rd1 = 0;

// RD signal active

delay(2);

led = data1;

// Move data (P2) to led (P1)

delay(300);

}

}