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.

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

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
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 code that i had developed is below for reference. It does not seem to work. (

1. Firstly even when i do not give an input signal to the ADC, the LED switches on
2. The LED switches on and than off (I suppose indicating that the S-ram has attained the required address)
3. The display always indicates 0; even though there is input signal in the ADC.
)

#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 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) {

WRITE=0; // AD conversion;
WRITE=1;
while(INTR==1);
delay();
BLANK=1;
P1=0xFF; // declaring P1 as input data after A/D conversion
READ=0;

advalue=P1; // assigning the input bits (A/D bits) to advalue
READ=1;
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=(*addr)*(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;


for(j=0;j<20000;j++);
}




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;

}



Could someone please tell me if there is anything wrong with my code. Thank you.
 

I have given example for interfacing ADC0804 with parallel port of computer in C. So i think that will help you. I used free running mode. For more details see my parallel port book

MY EXPERIENCE IN PARALLEL PORT INTERFACING
you can get it from yahoo group-booksbybibin
h**p://groups.yahoo.com/group/booksbybibin/
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top