Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Problem interfacing AT89C52 and HY62256(S-Ram)

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. Could someone please tell me if there is anything wrong with my code. 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 LED=P3^1;
unsigned int advalue,value,j;


void ex0_isr (void) interrupt 0 // interrupt that is activated whenever P3^2 goes low
{ P1=0xFF; // declaring P1 as input data after A/D conversion
advalue=P1; // assigning the input bits (A/D bits) to advalue
if(addr!=0xFFFF) // keep on storing the 8 bit values obtained from the ADC in address starting from 0x0000 till
// the S-RAM gets full.
{LED=1; // to check whether there is any conversion
for(j=0;j<2000;j++);
*addr++ =value;
LED=0; //to check whether there is any conversion
delay(); // delay function
}

else
{
EX0 =0; // If the S-ram is full, disable external interrupt 0 and the Global interrupt flag
EA=0;
}
}


void main(void){
EX0 = 1; // Enable EX0 Interrupt, this function is to enable (set) or disable(clear) External intrrupt 0
EA = 1; // Enable Global Interrupt Flag
IT0=0; // Interrupt 0 type control bit.Set/cleared by software to specify falling edge/low level triggered External interrupt
P1=0xFF; // Declaring P1 as an input

while(1) {

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

}
}



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;

}
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top