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 Communication Issue between F280039C and INA237

Part Number: LAUNCHXL-F280039C
Other Parts Discussed in Thread: INA237, SYSCONFIG, C2000WARE

Tool/software:

Hello TI Team,

I’m currently working on an I2C communication setup using the F280039C microcontroller (C2000 series) and the INA237 current/voltage monitor.

I tried interfacing the F280039C with the INA237 using the I2C peripheral, but I’m not getting any communication (no ACK response or valid data).
To confirm, I also tried I2C communication between F280039C and dsPIC33EP128GP504 as a test, but that also didn’t work — so I believe there may be an issue with my I2C configuration on the F280039C side.

Could you please share a I2C master example code for the F280039C. 

Also, please mention if there are any specific clock configuration or GPIO pinmux settings required for proper I2C operation on this device.

My setup:

  • MCU: F280039C LaunchPad

  • Sensor: INA237 (I2C interface)

  • I2C speed: Standard mode (100 kHz)

  • Toolchain: Code Composer Studio

Thank you for your help and guidance!

Best regards,
Antony Jose

  • Hi Antony,

    Are you using SysConfig for this project to do the I2C configuration? We have some example software in our C2000WARE SDK (also found here: https://dev.ti.com/tirex/explore/node?node=A__AAF3gzYRM8LuewELzUFZrg__C2000WARE__1kRFgrO__LATEST)

    Also which GPIOs are you using for I2C? There are some GPIOs on the F280039C LaunchPad which are disconnected by default so be sure you are making the necessary switch/board alterations to utilize these signals. Refer to the User Guide specifically


    Regards,

    Peter

  • Hi Peter,

    Thank you for your response.

    Yes, I’m using SysConfig for the I2C configuration in this project. I referred to the example from C2000Ware (i2c_ex1_loopback) as suggested. I selected this example because it is the first thing I wanted to test related to I2C.

    I tested the code in two ways:

    1. FIFO + Interrupt method:
    This setup works — I can observe the expected transmit and receive data correctly in loopback mode.

    2. Polling method (without FIFO and interrupts):
    This case is not available directly in SysConfig, so I modified the FIFO interrupt example. My observation is: the TX phase works, but the RX phase does not complete. It gets stuck on this line:

       while(!(I2C_getStatus(myI2C0_BASE) & I2C_STS_RX_FULL)) . 

    If I skip this check, the code triggers an assert error at next line.

    I am trying to use polling mode to communicate with an INA237 IC, which is why I am testing loopback in polling mode first.

    while(1)
        {
            for(i = 0; i < 8; i++)
            {
                // Wait until TX is ready
                while(!I2C_getStatus(myI2C0_BASE) & I2C_STS_TX_EMPTY) {}

                I2C_putData(myI2C0_BASE, sData[i]);
            }

            // Generate Stop condition
            I2C_sendStopCondition(myI2C0_BASE);

            for(i = 0; i < 8; i++)
            {
                // Wait for RX ready
                while(!(I2C_getStatus(myI2C0_BASE) & I2C_STS_RX_FULL)) {}

                rData[i] = I2C_getData(myI2C0_BASE);
            }

            I2C_sendStopCondition(myI2C0_BASE);

            //
            // Compare
            //
            for(i = 0; i < 8; i++)
            {
                if(rData[i] != sData[i])
                {
                    //GPIO_togglePin(DEVICE_GPIO_PIN_LED1);
                }
            }

            // Increment data
            for(i = 0; i < 8; i++)
            {
                sData[i]++;
            }

            DEVICE_DELAY_US(500000);
        }
    }
    Init function is like 
    void I2C1_init(){
        I2C_disableModule(I2C1_BASE);
        I2C_initController(I2C1_BASE, DEVICE_SYSCLK_FREQ, I2C1_BITRATE, I2C_DUTYCYCLE_50);
        I2C_setConfig(I2C1_BASE, I2C_CONTROLLER_SEND_MODE);
        I2C_disableLoopback(I2C1_BASE);
        I2C_setOwnAddress(I2C1_BASE, I2C1_OWN_ADDRESS);
        I2C_setTargetAddress(I2C1_BASE, I2C1_TARGET_ADDRESS);
        I2C_setBitCount(I2C1_BASE, I2C_BITCOUNT_8);
        I2C_setDataCount(I2C1_BASE, 1);
        I2C_setAddressMode(I2C1_BASE, I2C_ADDR_MODE_7BITS);
        I2C_disableFIFO(I2C1_BASE);
        I2C_clearInterruptStatus(I2C1_BASE, I2C_INT_REG_ACCESS_RDY | I2C_INT_STOP_CONDITION);
        I2C_enableInterrupt(I2C1_BASE, I2C_INT_REG_ACCESS_RDY | I2C_INT_STOP_CONDITION);
        I2C_setEmulationMode(I2C1_BASE, I2C_EMULATION_STOP_SCL_LOW);
        I2C_enableModule(I2C1_BASE);
    }

    For GPIO configuration — I’m using the pins assigned through SysConfig, I2CB :- GPIO34 as I2CB_SDA.  GPIO51 as I2CB_SCL. 

    I think I need to resolve this polling RX issue first before moving forward to communicate with INA237. Could you advise on the correct procedure to get polling-based loopback working on the F280039C?Additionally, I would appreciate any guidance on implementing polling-based or interrupt based I2C communication with the INA237 sensor. 

    Best regards,
    Antony Jose

  • Hi Antony,

    Can you refer to the i2c_ex4_eeprom_polling example in the SDK? That shows the preferred implementation for using polling-based I2C communciation

    Regards,

    Peter

  • Hi Peter, 

    I checked that, then it ends up in fail function. 

    void fail(void)
    {
        asm("   ESTOP0");
        for(;;);
    }
    Regards,
    Antony
  • Hi peter, 

    Just following up on my previous msg(sent 4 days ago) regarding the  issue.
    I checked the Code you suggested, but it still ends up entering the fail() function:

    void fail(void) { asm(" ESTOP0"); for(;;); }
    I also checked the SCL and SDA lines on the oscilloscope, but no signal activity was observed.

    Could you please advise on the next step or what additional details to do ?
    Antony

  • Hi Antony,

    Can you follow the call stack to see where it's throwing the fail() function? Ensure you're configuring the correct target address

    Regards,

    Peter