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

Problem writing and reading EEPROM by LPC2148 I2C0

how to simulate I2C by signal function, I am using LPC2148.
I used following code but not getting output

/ Simulation of I2C Memory (Slave)

MAP 0x80000000, 0x800000ff READ WRITE // Map User Memory region

DEFINE int SADR // Slave Address

signal void I2CMEMORY (void) { unsigned long adr;

adr = 0x80000000; while (1) { wwatch (I2C0_OUT); // Wait for data from Microcontroller while (I2C0_OUT == 0x0100) { // START detected wwatch (I2C0_OUT); // Wait for data from Microcontroller if (I2C0_OUT > 0xFF) continue; if ((I2C0_OUT >> 1) != SADR) continue; // test if Slave is addressed I2C0_IN = 0xFF00; // ACK to Microcontroller if (I2C0_OUT & 1) { // Slave Read while (1) { I2C0_IN = _RBYTE(adr); // Read Byte from Memory adr++; // Increment Address wwatch (I2C0_OUT); // Wait for ACK from Microcontroller if (I2C0_OUT != 0xFF00) break; } } else { // Slave Write wwatch (I2C0_OUT); // Wait for data from Microcontroller if (I2C0_OUT > 0xFF) continue; adr = I2C0_OUT + 0x80000000; // Set Memory Address I2C0_IN = 0xFF00; // ACK to Microcontroller while (1) { wwatch (I2C0_OUT); // Wait for data from Microcontroller if (I2C0_OUT > 0xFF) break; _WBYTE (adr, I2C0_OUT); // Store Byte in Memory adr++; // Increment Address I2C0_IN = 0xFF00; // ACK to Microcontroller } } } }
}

SADR = 0xA0
I2CMemory() // Start the signal function

I monitored the content of I2C0_OUT and I2C0_IN, value in I2C0_OUT changes but values in I2C0_IN is fixed to 0xFFFF;

Please help me

Parents
  • Read the posting instructions related to source code, then it might actually be readable.

    Simulation is unlikely to support external devices. Review pin signals with a scope or logic analyzer with respect to the EEPROM chip documentation and timing diagrams.

Reply
  • Read the posting instructions related to source code, then it might actually be readable.

    Simulation is unlikely to support external devices. Review pin signals with a scope or logic analyzer with respect to the EEPROM chip documentation and timing diagrams.

Children
No data