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.

[SOLVED] eeprom (93c46) interfacing with p89v51rd2

Status
Not open for further replies.

pravin b

Member level 5
Joined
May 20, 2012
Messages
85
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Location
Mumbai, India
Activity points
2,083
Hello friends,
This is the very first time I am interfacing microchip 93lc46b with 8051.
I have written a code to write 55 at memory location 5 and onwards. but when I check the registers in the programmer, I dont see any value written in location 5 and so on. I am hereby attaching the code, please review my code and guide me finding the missing things, if any.
I have checked the waveforms on port pins, they seems ok with appropriate delay.what should be my approach now?

i am attaching code for memory write in eewr.txt file here.
 

Attachments

  • eewr.txt
    1.1 KB · Views: 78

Do you need to send a EWEN command before you start programming to enable writing ? Also, it looks like you should bring SCLK low at the beginning of the write_mem routine, or the first data bit won't be clocked.
 
Hey FenTrac, Lately was pretty busy with life. Thanks for the hint, I worked accordingly did those changes in code. Trying to read from EEEPROM, but not successful so far. Can you just take a look at my code please?

Thanks.

However when I check on my serial port I receive "F0 F0", though I have written "78" in my memory location 0x01. I ensured my serial is working fine in this case.
 

Attachments

  • eewr_2.txt
    2.1 KB · Views: 62
Last edited:

Attached is a revised version of your original file eewr.txt. This was revised looking at information in the AT93C46 data sheet. The file is un-tested as a program. Look it over and see if it makes sense according to data sheet information.


View attachment eewr_upd.txt
 

Thanks FenTrac I have adopted some of your ways of writing program. However I am able to write data in memory but unable to read from memory, what could be possibly wrong?
 

The second file you posted eewr2.txt has a read routine. The main issue I see is that the AT89C46 EEPROM has 2 data pins, Data In - pin 3, and Data Out - pin 4. In your program there are only 3 connections defined to the p89v51rd2, SD, SCLK, and CS. If Data written to the EEPROM is using SD, you need another pin on the processor connected to Data Out from the EEPROM. SD does not have data read from the EEPROM on it.
 
I have shorted pins Data out & Data in i.e. pin 3 & 4 and connected to 8051 with "SD".
 

Yes, it's possible to use a bidirectional data line with 93xx eeproms. But you must release the data line by writing 1 to it after sending the address information.
 
In the descriprion for reading data in the data sheet, it states "It should be noted that a
dummy bit (logic “0”) precedes the 8- or 16-bit data output string."
You may need to take this into account in rd_mem() as well.
 
Last edited:
The data read action is O.K., but can be simplified. The LSB is zeroed before the conditional |1 is performed.
Code:
if(SD==1)
  rvalue=rvalue|1;
rvalue=rvalue<<1;

I also keep the point that there's no problem to use a bidirectional data line.

- - - Updated - - -

There's however a problem that no shift must be performed after reading the last bit. So preferably, the shift action should be placed at the loop begin.

Code:
for (...)
{
  rvalue=rvalue<<1;
  if(SD==1)
    rvalue=rvalue|1;
}
 
Thanks FvM to point that "point". :thumbsup: I have used shifting at the beginning of the loop now; Also the hardware is tested with other code & is working fine. But really clueless why its not working with my version of code.

- - - Updated - - -

Hello Guys, finally succeeded to read data from 93lc46b, Thanks for your valuable support.
Changes done in code are, 1. SD=1 before Data READ action loop.
2. Right shift at the beginning of loop to prevent loss of LSB, thanks FvM for this.
Code:
unsigned int rd_mem(unsigned int address)
{
	int m, command=0x0006;
	unsigned int rvalue=0;
	SCLK=0;
	CS=1;
	edelay(0);

	for(m=0;m<=2;m++)
	{
		if(command&0x0004)
			SD=1;
		else 
			SD=0;
		edelay(0);
		command=command<<1;
		SCLK=1;
		edelay(1);
		SCLK=0;
		edelay(1);
	}
	for(m=0;m<=5;m++)
	{
		if(address&0x0020)
			SD=1;
		else 
			SD=0;
		edelay(1);
		address=address<<1;
		SCLK=1;
		edelay(1);
		SCLK=0;
		edelay(1);
	}
	SD=1;
	edelay(2);
	for(m=0;m<=15;m++)
	{
		rvalue=rvalue<<1;
		SCLK=1;
		edelay(2);
		SCLK=0;
		if(SD==1)
			rvalue=rvalue|1;
		edelay(1);
	}
	CS=0;
	edelay(2);
	return rvalue;
}
However, I did write SD=0 before, to make port pin 1.5 as an "input" since I am performing the "reading" from memory. But then I thought its a redundant line, since I was reading "something" (may be garbage) from memory. So can anyone tell me the concept behind making SD=1? (if anything else than making it as input pin!). Is it mandatory to perform before every read action?

Thanks!

Releasing the data line? Can you explain please or provide reading material to me for this? @FenTrac & FvM
 
Last edited:

Good job, glad you got the EEPROM program working.

SD = 1 allows the pin to be used as an input or an output. This has to do with the nature of the P89V51RD2 ports. The datasheet says:

" Port 1 is an 8-bit bidirectional I/O port with internal
pull-ups. The Port 1 pins are pulled high by the internal
pull-ups when ‘1’s are written to them and can be used as
inputs in this state.
As inputs, Port 1 pins that are externally pulled LOW will
source current (IIL) because of the internal pull-ups.
P1.5, P1.6, P1.7 have high current drive of 16 mA."

If SD = 0, then it will sink current and an external device will be unable to pull it HIGH, so the pin is only an output in this state.

Manufacturer data sheets are a good source of information, although not always the easiest to read.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top