Hi all,
I successfully interfaced 24LC16 eeprom to MSP4302417 controller and the same code works for 24LC128 also but it only writes on first page 0x50 not above 0x51 etc can anyone tell me solution for this
EEPROMWRITE 24LC16
void I2C_EE_PageWrite(unsigned char* ee_buffer, unsigned char WriteAddr, unsigned char NumByteToWrite, unsigned int BlockAdd)
{
int i;
UCB0I2CSA = BlockAdd;
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
while((IFG2&0x08)==0x00);
for (i=0;i<10;i++);
for (i=0;i<10;i++); //delay
UCB0TXBUF = WriteAddr; //0x00;
while(UCB0CTL1&UCTXSTT); //Send the start condition
while((IFG2&0x08)==0x00);
for(i=0;i<NumByteToWrite;i++)
{
UCB0TXBUF = *ee_buffer;
ee_buffer++;
while((IFG2&0x08)==0x00); //check IFG2 for transmit interrupt flag
}
UCB0CTL1 |= UCTXSTP;
while(UCB0CTL1&UCTXSTP); //Send the start condition
for (i=0;i<10000;i++); //delay
}
EEPROM READ 24LC16
void I2C_EE_BufferRead(unsigned char* ee_buffer, unsigned char ReadAddr, unsigned int NumByteToRead, unsigned int BlockAdd)
{
int i;
UCB0I2CSA = BlockAdd;
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
while((IFG2&0x08)==0x00); //check IFG2 for transmit interrupt flag
for (i=0;i<10;i++); //delay
UCB0TXBUF = ReadAddr;
while(UCB0CTL1&UCTXSTT); //Send the start condition
while((IFG2&0x08)==0x00); //check IFG2 for transmit interrupt flag
UCB0TXBUF = 0x00;
//while(UCB0CTL1&UCTXSTT); //Send the start condition
while((IFG2&0x08)==0x00); //check IFG2 for transmit interrupt flag
UCB0CTL1 &= ~UCTR; //0xEF;//make it reciver
UCB0CTL1 |= UCTXSTT; // I2C TX, start condition
while((IFG2&0x08)==0x00); //check IFG2 for transmit interrupt flag
for (i=0;i<10;i++);
while(UCB0CTL1&UCTXSTT); //Send the start condition
for(i=0;i<(NumByteToRead-1);i++)
{
while((IFG2&0x04)==0x00); //check IFG2 for transmit interrupt flag
*ee_buffer = UCB0RXBUF;
ee_buffer++;
}
UCB0CTL1 |= UCTXSTP;
while((IFG2&0x04)==0x00); //check IFG2 for transmit interrupt flag
*ee_buffer = UCB0RXBUF;
while(UCB0CTL1&UCTXSTP); //Send the start condition
}
