This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MCB2300 interface with i2c serial EEPROM

> I got trouble when I write and read PCF8582 EEPROM with MCB2300 board using I2C.

> I have LPC2368 processor in MCB2300 board.

> I use I2C1 interface for read and write EEPROM.

> I got different characters other than in EEPROM.

> Should i require the external pullup resistor to connect with i2c line? Suggest me.

> or else problem with my code? Please suggest me.

> In advance thanks for help.

> I also can not write into EEPROM.

> This is my code for read EEPROM using current address read method.

#include<stdio.h>
#include<lpc23xx.h>

void init(void);
void start(void);
void slave_selectwrt(void);
void word_addr(void);
void slave_selectrd(void);
void data_rd(void);
void stop(void);
void delay(unsigned int cnt);

int main()
  {
  init();
  start();
  slave_selectwrt();
  word_addr();
  start();
  slave_selectrd();
  data_rd();
  stop();
  }

void init(void)
  {
  CCLKCFG = 0x8F;                               //  CCLK = 2MHz
  PCLKSEL0 |= 0x00000100;               //  UART1_pclk=CCLK
  PCLKSEL1 |= 0x00000040;               //      I2C1_pclk = CCLK
  PINSEL0 |= 0x40000000;                /* select pin function fot UART1 TXD*/
  PINSEL0 |= 0x0000000F;                /* select pin function fot I2C1 pin 66 & 67 */
  I21SCLH = 500;                                // make I2C1 bit FREQ = 100
  I21SCLL = 500;

/*-- UART1 configuration start--*/
  U1LCR = 0x83;
  U1DLM = 0;
  U1DLL = 0xD;                                  // baud rate = 9615
  U1LCR = 0x03;
  I21CONCLR = 0x6C;                             // clearing all flags
  I21CONSET = 0x40;                             // enabling I2C
  }

void start(void)
  {
  I21CONSET = 0x20;                             // start condition
  I21CONCLR = 0x08;                             // clear SI
  delay(1000);
  }

void slave_selectwrt(void)
  {
  I21DAT = 0xA0;                                /* EEPROM select + write bit*/
  I21CONCLR = 0x28;                             /* Clear start bit and SI*/
  delay(1000);
  }
void word_addr(void)
  {
  I21DAT = 0x01;
  I21CONCLR = 0x08;                             // clear SI
  delay(1000);
  }
void slave_selectrd(void)
  {
  I21CONCLR = 0x28;                             // Clear start bit and SI
  I21DAT = 0xA1;                                // EEPROM select + Read bit
  I21CONCLR = 0x08;
  delay(1000);
  }
void data_rd(void)
  {
  char k;
  delay(100);
  k = I21DAT;
  U1THR = k;                                    // Send data to Hyper terminal
  I21CONCLR = 0x08;                             // Clear SI
  delay(1000);
  }

void stop(void)
  {
  I21CONSET = 0x10;                             /* Send Stop condition */
  I21CONCLR = 0x08;                             // Clear SI
  delay(1000);
  }
void delay (unsigned int cnt)
  {
  while(cnt--);                                 // delay subroutine
  }

0