This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Has anyone got to work the example for i2c_EEPROM from CONTROLSUITE. It works when sending 1 or 2 bytes, but does not work for 3 to 14 bytes.

I'm using the 28F069 with the EEPROM cat24c128 from OnSemiconductors.

The only changes I made to the code was to change:

#define I2C_NUMBYTES          3

The example Example_2806xI2C_eeprom.c works for 1 or 2 bytes only. Once you go over 2 byte the program spins waiting to get out of BUSY. Never get the STOP condition to continue with the read function.

Reading the specs for the I2C I noticed that the FIFO is 4 deep, but we are transmitting 5 bytes; 2 bytes for the EEPROM address and 3 bytes in the for() loop.

I2caRegs.I2CDXR = msg->MemoryHighAddr     //byte 1

I2caRegs.I2CDXR = msg->MemoryLowAddr;    //byte 2

// for (i=0; i<msg->NumOfBytes-2; i++)

for (i=0; i<msg->NumOfBytes; i++)                       // NumOfBytes = 3

{
     I2caRegs.I2CDXR = *(msg->MsgBuffer+i);                //3 byte sent here
}

//The TX FIFO has been overwritten

// Send start as master transmitter
I2caRegs.I2CMDR.all = 0x6E20;

Does anyone have a version that works?

Thank you.

 

  • Julio,

    Unfortunately you have hit on a limitation of the I2C FIFO. There is a misleading comment in the header file example leftover from another device that has a 16 byte FIFO. The number 14 below should say 2.

    // Global variables
    // Two bytes will be used for the outgoing address,
    // thus only setup 14 bytes maximum
    struct I2CMSG I2cMsgOut1={I2C_MSGSTAT_SEND_WITHSTOP,
    I2C_SLAVE_ADDR,
    I2C_NUMBYTES,
    I2C_EEPROM_HIGH_ADDR,
    I2C_EEPROM_LOW_ADDR,
    0x12, // Msg Byte 1
    0x34}; // Msg Byte 2

    Regards,
    Dave Foley

  • Thank you David for the response:

    In the Technical reference SPRUH18E in section you read: 

    14.3.2 I2C FIFO Interrupts
    In addition to the seven basic I2C interrupts, the transmit and receive FIFOs each contain the ability to
    generate an interrupt (I2CINT2A). The transmit FIFO can be configured to generate an interrupt after
    transmitting a defined number of bytes, up to 4.

    In table 14.6 you read the following: 

    Table 14-6. Master-Transmitter/Receiver Bus Activity Defined by the RM, STT, and STP Bits of
    I2CMDR

    RM STT STP    Bus Activity          Description

    0        1      0       S-A-D..(n)..D.      START condition, slave address, n data bytes (n = value in I2CCNT)
    0        1      1       S-A-D..(n)..D-P   START condition, slave address, n data bytes, STOP condition (n =value in I2CCNT)

    There is a mode where you could send n data bytes in between START Condition and STOP condition (RM=0, STT=1, STP=1).

    I need to send START condition, SLAVE address, EEPROM address High, EEPROM address low. 64 Bytes, STOP condition.

    I have not been able to do that, could you please help me on how to accomplish that sequence?

    Thank you again

    Julio 

  • Hi Julio,
    You can't send 64 bytes at a time, split it with more number of transmissions with max number of bytes to be 14 in each transmission excluding EEprom address high and low.

    Regards
    Lakshhmi Tejas