BiPOM Forum

General => Microcontroller Development Systems => 8051 Development Tools => Topic started by: DanielD on October 11, 2004, 10:55:27 pm

Title: Writing EEprom
Post 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.  
Title: Re: Writing EEprom
Post by: vitaliy on October 12, 2004, 09:50:48 am
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
Title: Re: Writing EEprom
Post by: DanielD on December 01, 2004, 06:27:42 pm
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;
}
Title: Re: Writing EEprom
Post by: vitaliy on December 02, 2004, 04:27:05 am
Please note, you changed the original  source.
It had contained
....

   deviceNumber |= (address >> 8);
   ec = Transmit( I2C_DEVICE_24CXX | I2C_WRITE | (deviceNumber << 1) );
...
Title: Re: Writing EEprom
Post by: vitaliy on December 02, 2004, 04:28:13 am
sorry

   deviceNumber |= (address >> 8 ) ;

   ec = Transmit( I2C_DEVICE_24CXX | I2C_WRITE | (deviceNumber << 1) );
Title: Re: Writing EEprom
Post by: DanielD on December 02, 2004, 10:02:40 am
 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
Title: Re: Writing EEprom
Post by: DanielD on December 08, 2004, 07:18:36 pm
I have another question concerning eeproms.  Do you have a routine available for reading and writing on chip eeproms on the AT89C51ED2?  




Title: Re: Writing EEprom
Post by: vitaliy on December 09, 2004, 12:15:08 pm
Please download
http://www.bipom.com/support/T89C51Rx2_EEPROM.zip
Title: Re: Writing EEprom
Post by: DanielD on December 09, 2004, 10:07:10 pm
Thanks, I appreciate the help.

Daniel D