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 Mode

Other Parts Discussed in Thread: LM3S2965

Hello,

I'm using a Stellaris LM3S2965 controller which has to act as a slave and respond to the master by sending 2 bytes of data or a block of 12 bytes , how do i check if master has acknowledged a byte sent and continue to transmit till stop condition has been generated by the master  .

Regards

Abhay

  • Hi Abhay,

         I am not the expert here regarding I2C. Do a search in this forum and Stellaris forum regarding related posts. There are also example I2C codes at the example folder that you can review.

    -kel

  • Hi Markel,

     

    I did do a forum search and checked the examples before I wrote this post , none provide clarity on the master ack bit interrupt , instead there TREQ (Master Transmit Request) bit interrupt , I'm not sure if this interrupt is generated each time the master ack's a byte sent by the slave or just the first time

    Regards

    Abhay

  • Hi Abhay,

        I don't have the Stellarisware for your microcontroller. I think what you need is this code line(s) below . I got this from the master_slave_loopback.c example I2C code. See how the I2CSlaveStatus() function works.

    //
    // Wait until the slave has received and acknowledged the data.
    //
    while(!(I2CSlaveStatus(I2C0_SLAVE_BASE) & I2C_SCSR_RREQ))
    {
    }

    -kel

  • Abhay,

      In your I2C slave interrupt handler, you will call I2CSlaveIntStatus() to get the interrupt status. If I2C_SLAVE_INT_DATA is set, call I2CSlaveStatus() and you will see I2C_SLAVE_ACT_TREQ set whenever the master is requesting data from the slave.  Call I2CSlaveDataPut() at this point to send the next byte of the packet you are returning.

      In cases where the master is transferring data to the slave, the I2CSlaveStatus() call will return flags including I2C_SLAVE_ACT_RREQ indicating that you should call I2CSlaveDataGet() to read the newly received byte.

  • Thanks Dave !! I will get back to you after testing this !!

    Regards

    Abhay