Author Topic: Writing EEprom  (Read 17103 times)

DanielD

  • Guest
Writing EEprom
« 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.  

vitaliy

  • Full Member
  • ***
  • Posts: 30
    • View Profile
Re: Writing EEprom
« Reply #1 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

DanielD

  • Guest
Re: Writing EEprom
« Reply #2 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;
}
« Last Edit: December 01, 2004, 08:44:39 pm by DanielD »

vitaliy

  • Full Member
  • ***
  • Posts: 30
    • View Profile
Re: Writing EEprom
« Reply #3 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) );
...

vitaliy

  • Full Member
  • ***
  • Posts: 30
    • View Profile
Re: Writing EEprom
« Reply #4 on: December 02, 2004, 04:28:13 am »
sorry

   deviceNumber |= (address >> 8 ) ;

   ec = Transmit( I2C_DEVICE_24CXX | I2C_WRITE | (deviceNumber << 1) );

DanielD

  • Guest
Re: Writing EEprom
« Reply #5 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

DanielD

  • Guest
Re: Writing EEprom
« Reply #6 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?  





vitaliy

  • Full Member
  • ***
  • Posts: 30
    • View Profile
Re: Writing EEprom
« Reply #7 on: December 09, 2004, 12:15:08 pm »

DanielD

  • Guest
Re: Writing EEprom
« Reply #8 on: December 09, 2004, 10:07:10 pm »
Thanks, I appreciate the help.

Daniel D