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.

i2c_eeprom does not work with the Example_2806xI2C_eeprom

When the number of bytes to send is 1 or 2 it works; but when >2 it does not.

No changes to the code, I used the code without modifications.

I'm using my own board with the 320F28069 and the EEPROM is CAT24C128 from On semiconductor.

The signals look good and it works when sending two bytes.

When #define I2C_NUMBYTES    changes to 3 or 14 it does not generate the STOP condition.   

See the table below to see what I see in the SCOPE.  

numberOfBytes to send 1 Comment 2 Comment 3 Comment
  Works (pass)   Works (pass)   Works (pass)  
I2CMDR 0x6e20   0x6e20   0x6e20  
Scope capture            
     //STT      //STT      //STT,  
     //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50
     //0x01(ak), memory address H    //0x01(ak), memory address H    //0x01(ak), memory address H
     //0x30(ak), memory address L    //0x30(ak), memory address L    //0x30(ak), memory address L
     //0x12(ak), data 1    //0x12(ak), data 1    //0x12(ak), data 1
         //0x34(ak), data 2    //0x34(ak), data 2
     //STP      //STP      //SCL stays low & SDA goes high (missing data 3)  
     //STT      //STT      
     //0xA0(nk), slave address 0x50    //0xA0(wr&nk), slave address 0x50    
     //STP      //STP      
               
  //..repeats 83 times   //..repeats 83 times      
     //STT      //STT      
     //0xA0(wr&nk), slave address 0x50    //0xA0(wr&nk), slave address 0x50    
     //STP      //STP      
  //..repeats 83 times   //..repeats 83 times      
             
     //STT      //STT      
     //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50    
     //0x01(ak), memory address H    //0x01(ak), memory address H    
     //0x30(ak), memory address L    //0x30(ak), memory address L    
     //0x01(ak), ???????    //0x01(ak), ???????    
     //STT      //STT      
     //0xA1(rd&ak), slave address 0x50    //0xA1(rd&ak), slave address 0x50    
     //0x12(ak), data 1    //0x12(ak), data 1    
         //0x34(nk), data 2    
     //STP      //STP      

numberOfBytes to send 1 Comment 2 Comment 3 Comment
Works (pass) Works (pass) Works (pass)
I2CMDR 0x6e20 0x6e20 0x6e20
Scope capture
   //STT    //STT    //STT,
   //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50
   //0x01(ak), memory address H    //0x01(ak), memory address H    //0x01(ak), memory address H
   //0x30(ak), memory address L    //0x30(ak), memory address L    //0x30(ak), memory address L
   //0x12(ak), data 1    //0x12(ak), data 1    //0x12(ak), data 1
   //0x34(ak), data 2    //0x34(ak), data 2
   //STP    //STP    //SCL stays low & SDA goes high (missing data 3)
   //STT    //STT
   //0xA0(nk), slave address 0x50    //0xA0(wr&nk), slave address 0x50
   //STP    //STP
   
//..repeats 83 times //..repeats 83 times
   //STT    //STT
   //0xA0(wr&nk), slave address 0x50    //0xA0(wr&nk), slave address 0x50
   //STP    //STP
//..repeats 83 times //..repeats 83 times
   //STT    //STT
   //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50
   //0x01(ak), memory address H    //0x01(ak), memory address H
   //0x30(ak), memory address L    //0x30(ak), memory address L
   //0x01(ak), ???????    //0x01(ak), ???????
   //STT    //STT
   //0xA1(rd&ak), slave address 0x50    //0xA1(rd&ak), slave address 0x50
   //0x12(ak), data 1    //0x12(ak), data 1
   //0x34(nk), data 2
   //STP    //STP
  • Hello,
    I am not sure what is going on, but did you pull-up the SCL and SDA pins?

    Best regards,
    Maria
  • Yes, check hardware and is OK.
    As I said previously, the code works fine when I send 2 bytes, but more than 2 bytes it does not.
    According to the example comments, it should worked up from 2 to 14 bytes.
    It does not.
  • Is it really without modification?
    At least you need to modify the number of byte (#define I2C_NUMBYTES ) and the data in struct I2CMSG I2cMsgOut1.
  • I did change the number from 2 to 3 first.

    What you are telling me is that the example only works up to 2 bytes and if I want to send more bytes there are more changes that need to be done?

    I see only 2 changes necessary to send 3 bytes, unless I'm reading the code wrong:

    #define I2C_NUMBYTES 2                     //change this to 3

    0x12, // Msg Byte 1
    0x34, // Msg Byte 2
    0x56};                                   //add this byte to the struct I2cMsgOut1 (Msg Byte 3)

    because the buffer size should be ok.

    #define I2C_MAX_BUFFER_SIZE       4

    Am I missing something?

    Thank you

     

  • Did you already try the ones that you mentioned above?
  • Hello: yes.

    Here is the actual bytes and start stop condition read from the oscilloscope.

    numberOfBytes to send --> 1 Comment 2 Comment 3 Comment
      Works (pass)   Works (pass)   Fail  
    I2CMDR 0x6e20   0x6e20   0x6e20  
    Scope capture            
         //STT Start Condition    //STT Start Condition    //STT, Start Condition
         //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50
         //0x01(ak), memory address H    //0x01(ak), memory address H    //0x01(ak), memory address H
         //0x30(ak), memory address L    //0x30(ak), memory address L    //0x30(ak), memory address L
         //0x12(ak), data 1    //0x12(ak), data 1    //0x12(ak), data 1
             //0x34(ak), data 2    //0x34(ak), data 2
         //STP Stop Condition    //STP Stop Condition    //SCL stays low & SDA goes high (missing data 3)  
         //STT Start Condition    //STT Start Condition   Missing Stop condition
         //0xA0(nk), slave address 0x50    //0xA0(wr&nk), slave address 0x50    
         //STP Stop Condition    //STP Stop Condition    
                   
      //..repeats 83 times   //..repeats 83 times      
         //STT Start Condition    //STT Start Condition    
         //0xA0(wr&nk), slave address 0x50    //0xA0(wr&nk), slave address 0x50    
         //STP Stop Condition    //STP Stop Condition    
      //..repeats 83 times   //..repeats 83 times      
                 
         //STT Start Condition    //STT Start Condition    
         //0xA0(wr&ak), slave address 0x50    //0xA0(wr&ak), slave address 0x50    
         //0x01(ak), memory address H    //0x01(ak), memory address H    
         //0x30(ak), memory address L    //0x30(ak), memory address L    
         //0x01(ak), ???????    //0x01(ak), ???????    
         //STT Stop Condition    //STT Start Condition    
         //0xA1(rd&ak), slave address 0x50    //0xA1(rd&ak), slave address 0x50    
         //0x12(ak), data 1    //0x12(ak), data 1    
             //0x34(nk), data 2    
         //STP Stop Condition    //STP Stop Condition    

    Write 2 bytes and it was ok. Software stops in void pass();

    Sequence is 0x50(write address), 0x00, 0x00, 0x12, 0x34 and then loops writing 83 consecutive 0x50 with NAKS as responses, then writes a 0x50 and gets ACk as response. See next image that shows the last 0x50 with a NACK. GOOD WRITE CYCLE.

    Read 2 bytes and it was ok. Software stops in void pass();

    Showing Last NACK then the Sequence is 0x50(write address), 0x00, 0x00, 0x00(what is this data?), 0x50(read address), 0x12, 0x34 and ends with Stop condition. GOOD READ CYCLE.

    Next Wrote 3 bytes. Using the same code as before but change the bytes to send to 3.

    #define I2C_NUMBYTES 3 //ja-was 2.

    This is the failure capture.

     Sequence is 0x50(write address), 0x00, 0x00, 0x12, 0x34 with ACK but SCL stays low.