Discussion in "8051 Discussion Forum" started by    desiato    Nov 28, 2007.
Wed Nov 28 2007, 11:29 am
#1
im trying to interface at28c64b to 89c51
but its not working, please help
i must finish this within this week!

connection:
/ce->0
/oe(74hc737n)->0
P0->(d0-d7)(74hc737n)(q0-q7)->(a0-a7)(at28c64b)
P2->(a8-a12)(LE)(/we)(at28c64b /oe)

ill give the schamtic very soon.

this is the code



#include <REG52.H>
//13-bit address,8-bit input
#define MDATA P0
#define ADDR1 P0
#define ADDR2 P2

sbit LE  =              ADDR2^5; //   LE
sbit WE  =              ADDR2^6; //   /WE
sbit OE  =              ADDR2^7; //   /OE

sbit IO7 =              MDATA^7; // /data polling
sbit IO6 =              MDATA^6; // toggling bit

#define MASK_W 0xE0 //11100000B
#define MASK_R 0x60 //01100000B

//can write only 5ms after power on
void write_eep(unsigned short int addr,unsigned char dat){
    bit last_bit=dat^7;
    OE=1; //in
    WE=1; //r
    ADDR1=addr&0xff;
    ADDR2=(addr>
>
8)|MASK_W;
    LE=1; //latch-in on
    LE=0; //latch-in off
    WE=0;
    MDATA=dat;
    WE=1;
    WE=0;
    //wait for the write cycle to end
    while(IO7==last_bit);    
}

unsigned char read_eep(unsigned short int addr){
    WE=1; //read
    OE=0; //in
    ADDR1=addr&0xff;
    ADDR2=(addr>
>
8)|MASK_R;
    LE=1; //latch-in on    
    LE=0; //latch-in off
    OE=0; //out
    MDATA=0xff;
    //reset
    return MDATA;    
}

//hundreds thx




[ Edited Wed Nov 28 2007, 01:25 pm ]
Wed Nov 28 2007, 01:27 pm
#2
check what is the voltage required to write to that EEPROM. and i want to see the circuit too..
Wed Nov 28 2007, 03:34 pm
#3
thx

here is the circuit
Attachment


5v is needed to write.

let me know if anyone want anything about it.






[ Edited Wed Nov 28 2007, 03:43 pm ]
Wed Nov 28 2007, 04:23 pm
#4
I checked the datasheet, and i feel there is a problem with the write operation, at the end where you are doing DATA POLLING.

void write_eep(unsigned short int addr,unsigned char dat){
    bit last_bit=dat^7;
    OE=1; //in
    WE=1; //r
    ADDR1=addr&0xff;
    ADDR2=(addr>
>
8)|MASK_W;
    LE=1; //latch-in on
    LE=0; //latch-in off
    WE=0;
    MDATA=dat;
    WE=1;
//    WE=0;
// No need to make WE 0 as you are reading so OE has to be low
    OE = 0;
// See datasheet at "data polling waveform"
    //wait for the write cycle to end
    while(IO7==(~last_bit));
// As per the datasheet IO7 will have complement of last written data
// and so you wait till the IO7 is showing complement of last bit
// when the write cycle is complete the correct data will be shown.
    OE = 1;
}

I have made corrections according to whatever mentioned in the datasheet. Please check it and let me know.
Thu Nov 29 2007, 05:33 pm
#5
it doesn't seem to work and i'm trying to use a serial eeprom, at24c64a instead, but its still not working.
could anyone give me some sample code for at24c64a /24c64? i've been searching for long, but found none working. plz help
Thu Nov 29 2007, 05:47 pm
#6
why don't you try giving some delay of about 100 to 150ms instead of data polling, i think the main problem in your code is of that only.
  like this.
Fri Nov 30 2007, 12:42 pm
#7
you're right , i put some delay after the write function and it works, thx alot!
i was trying to make the code faster , so forgot delays


[ Edited Fri Nov 30 2007, 12:44 pm ]
Fri Nov 30 2007, 06:45 pm
#8
great... to know it worked.. remember.. hardware (the real thing) needs delay.. and software is always fast..
Sat Dec 01 2007, 02:21 am
#9
o, the serial eeprom is not working again.....
i don't change any of its wires nor code, everything are in the same old place , and the code is the same old code, but the rom just doesn't work. i can't write anything into it. any idea?


[ Edited Sat Dec 01 2007, 02:22 am ]
Sat Dec 01 2007, 02:25 am
#10
i thought you are using parallel ROM?
check the WP (write protect) signal.. or loose connection :-s

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am
Anthonyvab
Wed Apr 17 2024, 08:48 am
RobertCix
Wed Apr 17 2024, 06:46 am