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 Slave Device



Are there examples on how to use the Tiva C Microcontrollers (TM4C123G specifically) as a slave device?  The examples I see in the EK seem geared toward master mode.  Even the loopback seems to about responding to another Tiva C master.  I'm looking to have an external device read values from my microcontroller as if it was an eeprom.  I'm looking to have an external access trigger an interrupt somehow but don't see how to link the two.  At which point I assume  I can use I2CSlaveStatus() in conjunction with I2CSlaveDataPut() & I2CSlaveDataGet() to handle the various accesses something like an eeprom would need to handle(read address, read consecutive).  I was just hoping there might be a simple example to get me started but I only see Master and loopback stuff that isn't very helpful.  But I don't know how to recognize start and stop signals with the library of functions in the EK.  They seem very high level and I don't know how to use them to handle the signals that will be coming in.  I've done it on on other processors using serial bit manipulation via gpio lines but there seems to be additional functions needed. 

  • Hi,

    First thing to do is to search this forum for similar problems. I have found this:

    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/290599.aspx

    and look at Dave's response. It should be obvious for an experimented person like you.

    Petrei

  • That I have already seen.  It's also found in the master_slave_loopback example I mentioned.  I was hoping for something else.  This is just an oversimplified example.  I'd like to find more information or a better example.  I've been unable to find more documentation regarding what causes the interrupt, how to know there has been a transition, a stop, ....  I don't know what to look for after I get a TREQ and put a byte.  Can I simply spin on status again?  Does NONE mean it sent a stop or that nothing has happened yet?  It's all very vague and everything seems to be geared towards master mode or responding to the microcontrollers master mode.  I'm curious about responding to an external master that isn't another tiva microcontroller.  The master seems to have start, ack, finish, and so on.  I only see NONE, RREQ, and TREQ for the slave.  And nothing that uses this in any way besides spin on status and put data.  

  • Hi,

    Some more examples here:

    a)http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/214226.aspx
    b)Tiva/examples/peripherals/i2c/slave_receive_int.c
    c1)http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/214226.aspx
    c2)http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/235926.aspx
    Maybe will not answer all your questions, but there are at least some examples. Note c1) and c2) refers to master, but  you will find some info about some sniffer routines to help you with I2C.
    Also, all driverlib routines code is available, can be read/analyzed...
    Petrei
  • Hi Tim

    Detetcting START-STOP conditions on the Slave can be done using the Interrupt. Only if the Address sent by master matches the Slave Address programmed will a Start Interrupt be generated.

    On recieving a byte you would get a DATA Interrupt which can then be used in conjunction with RREQ status to read the data from I2CSDR register. When the Slave is referred to as Transmitter , it would get a DATAIM with TREQ bit set and this must be used by the code to write to the I2CSDR register. On Successful transmission the DATA Interrupt will be set if there is more data to be transmitted

    Hope that helps

    Amit