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.

CCS/TM4C129CNCPDT: TIVA4C1294XL-EK Firmware I2C Interrupt Registers not updating

Part Number: TM4C129CNCPDT

Tool/software: Code Composer Studio

Hello TI ForumI2C_Loop_Back_Mode.docx

I2C in Master Slave Loop back Mode as per TIVA Libraries and code is 

1)Not able to update the I2C registers 

2)Stuck in  

// Wait until the slave has received and acknowledged the data.

       //

       while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ))

       {

       }

3) Can we resolve this issue and make it non blocking Mode and get the I2C_SIMR & I2C_SRIS registers to respond??

Attached word doc of code and registers and UART Status

Thanks 

Krishna.P.N.

  • Hi,

    I checked the example code and I found two issues. I apologize that the original code is not correct. (I am very surprised that this issue was not reported earlier as this example is quite old and has been carried from one TivaWare release to the next.)

    The first issue is that the call to I2CSlaveIntEnableEx() is before the call to I2CSlaveEnable(). Therefore the slave interrupt was never enabled. The second issue is that the variable g_bIntFlag must be declared volatile. Otherwise the optimizer will not force a reread of the ram location in the while(!g_bIntFlag) loop.

    I have attached a .zip file for a Code Composer Studio version 9 project that has the corrected example.

    /cfs-file/__key/communityserver-discussions-components-files/81/I2C_2D00_slave_5F00_receive_5F00_int.zip

  • Hi Bill

    Thanks we will recheck with the code modifications and let you know

    Regards

    Krishna.P.N.

  • Hello Bob

    We have made changes to the code as advised

    1. volatile  g_bIntFlag;

    2. I2CSlaveEnable(I2C0_BASE);

    3. I2CSlaveIntEnableEx(I2C0_BASE, I2C_SLAVE_INT_DATA);

    In debug mode the code gets stuck at 

    while(!g_bIntFlag) 

    Only 1 byte of Data is sent as UART Dump is below

    I2C Loopback Example ->
    Module = I2C0
    Mode = Single Send/Receive
    Rate = 100kbps

    Tranferring from: Master -> Slave
    Sending: 'I' . . .
    Transmit data successfully!
    Received: '' . . . Sending: '2' . . .

    Actual Data sent and received should be "I", "2", "C" as this is loop back mode 

    Debug Registers

    I2C_SRIS Reg=0x0000007

    I2C_SIMR_DATAIM=0X0000001

    I2C_SMIS=0X0000001

    Thanks 

    Krishna.P.N.

  • The code I sent you as written only sends "I". The function I2CMasterDataPut() is only called once. Therefore, only an "I" is received. This was just to demonstrate the use of I2C interrupts. You can expand on this example to send more characters as you please.