TO PEg,Rhinocerohead and Bigmac,please help with this code.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TO PEg,Rhinocerohead and Bigmac,please help with this code.

3,531 Views
ganimides
Contributor I
Hi Guys !,,,how do you do????
 
Guys I`m not familiar with Eeprom using and I just need to modify this 24LC16 code to run a 24LC256 one.According to the code I attached below could you modify it so that I can run a 24LC256 one?.
 
 
Thanks a lot and have a nice week!!.
 
 
Ganimides.
Labels (1)
0 Kudos
4 Replies

459 Views
bigmac
Specialist III
Hello Ganimides,
 
The main difference between the 24LC256 and the 24LC16 is that the larger device needs an extra address byte to be sent to it.  So to compare what you would need to send to the each device -
 
24LC16:
1. Control byte - 1 0 1 0 B2 B1 B0 R/W
2. Address value within block (page)
 
B0-B2 provides block selection - only a single device is permitted.
 
24LC256:
1. Control byte - 1 0 1 0 B2 B1 B0 R/W
2. High address value (bits 0 to 6 only)
3, Low address value
 
B0-B2 provides device selection for use of multiple devices.
 
Regards,
Mac
 
0 Kudos

459 Views
ganimides
Contributor I
Thank you dear Bigmac but I`m affraid that I didn`t quite catch what you say...Ì`m the person who understands graphically.I just need to touch the necessary routines to run it.Therefore I sent the code to see if someone more experimented than me could help me to resolve it.
 
THank you so much for your support as always.
 
 
Ganimides.
0 Kudos

459 Views
bigmac
Specialist III
Hello Ganimides,
 
The following modified code might work , but has not been tested.  Note the new parameter device, to represent the hard-wired device selection associated with the 'LC256.  Incidentally, I think there would be a problem with your 'LC16 code when programming any page other than zero page.
 
void WriteEEbyte(byte device, word addr, byte data)
{
  ACK_flag = 0;
  Address = addr;
  StartBit();
  WriteIICbus(SLAVE_ADDRESS | ((device & 0x07)<<1)
);
  asm nop;
  Read_ACK();
  asm nop;
  if(ACK_flag !=0)
  {
    StopBit();
    return;
  }
  WriteIICbus(Addr_H & 0x7F);
  Read_ACK();
  if(ACK_flag !=0)
  {
    StopBit();
    return;
  }
  WriteIICbus(Addr_L);
  Read_ACK();
  if(ACK_flag !=0)
  {
    StopBit();
    return;
  }
  WriteIICbus(data);
  Read_ACK();
  StopBit();
}
//********************************************************************
void ReadEEbyte(byte device, word addr)
{
  ACK_flag = 0;
  Address = addr;
  StartBit();
  WriteIICbus(SLAVE_ADDRESS | ((device & 0x07)<<1)
); // RW bit = 0
  asm nop;
  Read_ACK();
  asm nop;
  if(ACK_flag !=0)
  {
    StopBit();
    return;
  }
  WriteIICbus(Addr_H & 0x7F);
  Read_ACK();
  if(ACK_flag !=0)
  {
    StopBit();
    return;
  }
  WriteIICbus(Addr_L);
  Read_ACK();
  if(ACK_flag !=0)
  {
    StopBit();
    return;
  }
  StartBit();
  WriteIICbus((SLAVE_ADDRESS | ((device & 0x07)<<1)
) | 1); // RW bit = 1
  Read_ACK();
  if(ACK_flag !=0)
  {
    StopBit();
    return;
  }
  DIR_SDA = 0;
  RD_data = GetByte();
  StopBit();
}
Regards,
Mac
 
 
0 Kudos

459 Views
ganimides
Contributor I
Thank you very much Bigmac for you explanation.
 
I have no doubt that your code will be working properly because till now every code you teached me and send me worked fine.I believe in your technical criteria.
 
I send you a big hug!.
 
 
Bye!.
 
 
Ganimides
0 Kudos