BiPOM Forum
General => Microcontroller Development Systems => 8051 Development Tools => Topic started by: DanielD on October 11, 2004, 10:55:27 pm
-
Need to know instruction or routine to write eeprom on min/max51. Can it be written one byte at a time.
-
If you use 8051/52 development system
you will be able to find EEPROM example under
C:\\bipom\\devtools\\MicroC\\Examples\\8051\\tiny\\eeprom\\24C04 folder.
Please try it.
Best regards,
Vitaliy
-
Thank you very much for the help. However, I have another problem. If I write to an eeprom address over 255 (8 bits) it writes to the target address and also to the target address minus 256. For example if I write to 256 it will write the data to address 256 and address 0. Any solutions for this? Is there a format for writing the address over 256? I\'m using WriteByte from the example programs on a MinMax51c with a T89C51RD2 and serial eeprom.
WriteByte( deviceNumber, address, data )
UBYTE deviceNumber;
unsigned address;
UBYTE data;
{
ERRCODE ec;
unsigned temp;
ec = Start();
if( ec != SUCCESS )
return ec;
ec = Transmit( I2C_DEVICE_24CXX | I2C_WRITE | (deviceNumber << 1) );
if( ec != SUCCESS )
goto func_end;
ec = Transmit( address & 0xFF );
if( ec != SUCCESS )
goto func_end;
ec = Transmit( data );
printf("\\nWriteByte=%d",data);
if( ec != SUCCESS )
goto func_end;
func_end:
Stop();
return ec;
}
-
Please note, you changed the original source.
It had contained
....
deviceNumber |= (address >> 8);
ec = Transmit( I2C_DEVICE_24CXX | I2C_WRITE | (deviceNumber << 1) );
...
-
sorry
deviceNumber |= (address >> 8 ) ;
ec = Transmit( I2C_DEVICE_24CXX | I2C_WRITE | (deviceNumber << 1) );
-
Vitaliy,
I don\'t know how I made that mistake (I originally pasted it into my code), but thanks, I was really having trouble finding the error.
Dan
-
I have another question concerning eeproms. Do you have a routine available for reading and writing on chip eeproms on the AT89C51ED2?
-
Please download
http://www.bipom.com/support/T89C51Rx2_EEPROM.zip
-
Thanks, I appreciate the help.
Daniel D