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.

[51] EEPROM 9346 interface

Status
Not open for further replies.

ssk_programmer

Newbie level 3
Newbie level 3
Joined
Dec 19, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
29
hello,
here is my code for 9346 interface with 8051. I have simulate it on simulator but on hardware its not working. I didn't understand what is remaining in this code anybody will help me..??

#include<reg51.h>

void E_EWEN();
void E_read(void);
void E_write();

//EEPROM PORTPINS
sbit E_CS= P2^0;
sbit ADC_CLK = P2^4;
sbit ADC_DIN= P2^5;
sbit ADC_DOUT = P2^6;

unsigned char bdata eep_buf; // eeprom's data buffer
sbit shift7 = eep_buf^7; // bit7 of data buffer
sbit shift0 = eep_buf^0; // bit0 of data buffer
unsigned char eep_addrs, eep_data;
unsigned char DATA, ADD;

void main()
{
while(1)
{
eep_addrs=0x01;
eep_data=0x11;
E_write();

ADD = 0X01;
E_read();
P0=DATA;
}

}


void E_read(void)
{
unsigned char count=0;
E_CS=1;
ADC_DIN=1;
ADC_CLK=1;
ADC_CLK=0;
ADC_CLK=1;
ADC_CLK=0;
ADC_DIN=0;
ADC_CLK=1;
ADC_CLK=0;

eep_buf=ADD;

while(count<7) //to wr addrs
{
eep_buf=(eep_buf<<1);
ADC_DIN=shift7;
ADC_CLK=1;
ADC_CLK=0;
count++;
}

count=0;
// eep_buf = 0;
while(count<8) //to read data
{
shift0=ADC_DOUT;
//eep_buf=ADC_DOUT;
eep_buf=(eep_buf<<1);
ADC_CLK=1;
ADC_CLK=0;
count++;
}
DATA=eep_buf;
E_CS=0;
}

void E_EWEN()
{
unsigned char count=0;
E_CS=1;
ADC_DIN=1;
ADC_CLK=1;
ADC_CLK=0;
ADC_DIN=0;
ADC_CLK=1;
ADC_CLK=0;
ADC_CLK=1;
ADC_CLK=0;
ADC_DIN=1;
ADC_CLK=1;
ADC_CLK=0;
ADC_DIN=1;
ADC_CLK=1;
ADC_CLK=0;

/* eep_buf=0x60;
while(count<7)
{
eep_buf=(eep_buf<<1);
ADC_DIN=shift7;
ADC_CLK=1;
ADC_CLK=0;
count++;
}
*/ E_CS=0;
}

void E_write()
{
unsigned char count=0;
E_EWEN();

E_CS=1;
ADC_DIN=1;
ADC_CLK=1;
ADC_CLK=0;
ADC_DIN=0;
ADC_CLK=1;
ADC_CLK=0;
ADC_DIN=1;
ADC_CLK=1;
ADC_CLK=0;

count = 0;
eep_buf=eep_addrs;
while(count<7)
{
eep_buf=(eep_buf<<1);
ADC_DIN=shift7;
ADC_CLK=1;
ADC_CLK=0;
count++;
}


count=0;
eep_buf=eep_data;
while(count<8)
{
ADC_DIN=shift7;
eep_buf=(eep_buf<<1);
ADC_CLK=1;
ADC_CLK=0;
count++;
}
E_CS=0;
delay(2);
E_CS= 1;
while(ADC_DOUT==0); //wait until busy
E_CS=0;

}
 

which controller you are using and which compiler you are using??
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top