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.

help needed in interfacing ADC0804 and HY62256(S-ram) to

Status
Not open for further replies.

vinash

Member level 2
Joined
Nov 3, 2005
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,999
adc0804 + project

Hi,
I have tried to interface ADC0804 and HY62256(S-ram) to AT89C52 microcontroller. The whole idea is to do an A/D conversion using ADC 0804 and than storing the data input to the SRAM. The Value that is stored on the SRAM is displayed on the HP display to check whether the value stored is the same as the input to the ADC.The code that i had developed is below for reference. It does not seem to work. The Display does not show the signal input. The schematic is in the attachment. Could someone please help me. Thank you.

#include <reg52.h>

void delay(void);
unsigned char xdata * data addr = 0x0000; // declares a pointer staring from external memory address of 0x0000
sbit WRITE=P3^0; // defining the WR and INTR pins
sbit INTR=P3^2 ;// The INTR pin is connected to the INTO pin, so that whenever it goes low, it cause an interrupt
sbit READ=P3^3; //This is the READ pin ( for ADC)
sbit LED=P3^1;
sbit CS=P3^4; // Used as Chip select for ADC0804
sbit BLANK=P3^5; // I am using HP 5082-7340 (display) and the display blanks when this pin goes high
unsigned int advalue,value,j,converted,k;
scanled (); // to display the ADC value on HP 5082-7340 display






void main(void){


while(1) {
P1=0xFF; // declaring P1 as input data after A/D conversion
BLANK=1; // Blank the Display
CS=0; // To enable the ADC chip

WRITE=0; // AD conversion;
WRITE=1;
while(INTR==1);
delay();

READ=0;

advalue=P1; // assigning the input bits (A/D bits) to advalue
delay();
READ=1;
CS=1; //To disable the ADC,so that no conversion occurs
for (j=0;j<20;j++){delay();} // delay for about 1 second

if(addr<=0x0014) /* keep on storing the 8 bit values obtained from the ADC in address starting from 0x0000 till
the S-RAM stores data till the address reaches 0x0014 */
{LED=1; // to check whether there is any conversion (by toggling the LED)
*addr++ =advalue; // to store the values into the address
LED=0;
scanled(); // to display the input signal value on an adc
delay();
} //to check whether there is any conversion

else{
LED=1;
}

delay();


}
}


scanled()
{
unsigned int a[10]={0xE0,0xF0,0xE1,0xF1,0xE2,0xF2,0xE3,0xF3,0xE4,0xF4}; // Configuration for display from 0-9
P1=0x00; // declare P1 as output
BLANK=0; // The Blank is made low so that the HP display shows numbers
converted=(advalue)*5/256; // Convert the ADC value obtained so that the input signal is between 0-5V;
P1=a[converted%10]; // Display the value on Port1;



}




void delay (void) // Delay function using Timer 0 for 50ms.
{
TMOD &=0xF0;
TMOD |=0x01;
ET0 =0;
TH0 =0x3C;
TL0 =0xB0;
TF0 =0;
TR0 =1;
while(TF0==0);
TR0=0;

}
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,310
Reputation
4,622
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,416
how to write adc into xdata

Lets have a look at the hardware part of your project ..
First of all, the ADC0804 is an older design utilizing 8-bit data bus that is compatibile with 8048/8051 microcontrollers ..
If I were you I would connect DB0-DB7 of the ADC directly to AD0-AD7 of the 89C52, INTR(5) pin connected to INT0 (P3.2), RD and WR connected to both ADC and SRAM through a couple of gates and selected by A15 (P2.7) in such a way that the addresses up to 7FFFh are reserved for SRAM and anything above 8000h indicates ADC ..
You don't need 74LS245, and P1 port will be dedicated to the HP LED display ..

As far as the sofware is concerned, try to commission your project block by block ..
For example, start with LED display, and try to display 1234, or whatever you like ..
Once this is done concentrate on ADC and try to display data from ADC.. so on ..

Regards,
IanP
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top