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.

TM4C1294NCPDT: TM4C1294NCPDT

Part Number: TM4C1294NCPDT

Dear Sir.,

I am using TM4C1294NCPDT TI Microcontroller. We had develop software ,for  read the inputs from microcontroller using I2C communication protocol. Every time Power up sequence the input reads zero, so we written a code like,

if(SPI_CS_Test_03==1)
{
g_LSU_DigitalInput_01_Flags = ~I2CReceive(g_LSU_DigitalInput_01_Slave_Address,g_DigitalInput_register);
g_LSU_DigitalInput_02_Flags = ~I2CReceive(g_LSU_DigitalInput_02_Slave_Address,g_DigitalInput_register);
SPI_CS_Test_03 = 0;

}

We add this case in main logic.Kindly solve the issue as soon as possible

  • Hello Tom,

    I'm sorry but while you are describing well what you are doing with the code, I don't see a problem statement regarding what the specific error is.

    Best Regards,

    Ralph Jacobi

  • Hi Ralph Jacobi,

    I am using TN4C1294NCPDT microcontroller, in our hardware unit we added some input switches for some applications. This input switches are connected from TCA9534APWR IO Expander IC.And  we connected 4 IO Expander IC with different slave address.

    In this above schematic The interrupt pin going to connect with microcontroller.And we writter the code be like,

    void GPIOIntHandler (void)
    {
    uint32_t ui32Status;
    ui32Status = GPIOIntStatus(GPIO_PORTQ_BASE,true);
    GPIOIntClear(GPIO_PORTQ_BASE, GPIO_PIN_0);
    if(((ui32Status & GPIO_PIN_0)>>0))
    {
    g_LSU_DigitalInput_01_Flags = ~I2CReceive(g_LSU_DigitalInput_01_Slave_Address,g_DigitalInput_register);

    }

    }

    We written the code was same as for four interrupt pins.
    The I2C read sequence is ,

    uint8_t I2CReceive(uint32_t slave_addr, uint8_t reg)
    {
    I2CMasterSlaveAddrSet(I2C1_BASE, slave_addr, false);
    I2CMasterDataPut(I2C1_BASE, reg);
    //I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    while(I2CMasterBusy(I2C1_BASE));
    I2CMasterSlaveAddrSet(I2C1_BASE, slave_addr, true);
    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    while(I2CMasterBusy(I2C1_BASE));
    return I2CMasterDataGet(I2C1_BASE);

    The above code is working fine during running sequence.In power up sequence , we could use both edges so it cannot sense.

    GPIOPadConfigSet(GPIO_PORTP_BASE,(GPIO_PIN_5),GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
    IntRegister(INT_GPIOP5,RSU_01_GPIOIntHandler);
    GPIOIntTypeSet(GPIO_PORTP_BASE, GPIO_PIN_5, GPIO_BOTH_EDGES);
    GPIOIntEnable(GPIO_PORTP_BASE, GPIO_INT_PIN_5);

    so we decided to read the I2C read sequence during power up, configure this I2C interrupt  sequence in this initialization part, for the below code:

    void MasterController_Initialize(void)
    {
    System_Control_Initialize();
    MasterController_StatusLED_Initialize();
    LSU_Drum_Pluse_GPIO_Initialize();

    I2C_Initialize();
    IO_Expander_Interrupt_Initialize();
    UART3_Initialize();

    g_LSU_DigitalInput_01_Flags = ~I2CReceive(g_LSU_DigitalInput_01_Slave_Address,g_DigitalInput_register);
    g_LSU_DigitalInput_02_Flags = ~I2CReceive(g_LSU_DigitalInput_02_Slave_Address,g_DigitalInput_register);
    g_RSU_DigitalInput_01_Flags = ~I2CReceive(g_RSU_DigitalInput_01_Slave_Address,g_DigitalInput_register);
    g_RSU_DigitalInput_02_Flags = ~I2CReceive(g_RSU_DigitalInput_02_Slave_Address,g_DigitalInput_register);

    }

    Our requirement is read the correct inputs using I2C read sequence.

  • Hi Tom,

    Thanks for the added detail and sharing that code, actually I think I have an immediate idea here on what might be going on because this is a TM4C1294 device.

    For TM4C1294 I2C the following is recommended after any commands where the master module is transferring data:

        //
        // Wait until master module is done transferring.
        // The I2C module has a delay in setting the Busy flag in the register so
        // there needs to be a delay before checking the Busy bit.  The below loops
        // wait until the Busy flag is set, and then wait until it is cleared to
        // indicate that the transaction is complete.  This can take up to 633 CPU
        // cycles @ 100 kbit I2C Baud Rate and 120 MHz System Clock.  Therefore, a
        // while loop is used instead of SysCtlDelay.
        //
        while(!MAP_I2CMasterBusy(I2C7_BASE))
        {
        }
        while(MAP_I2CMasterBusy(I2C7_BASE))
        {
        }

    So you should update your code to be as follows:

    I2CMasterSlaveAddrSet(I2C1_BASE, slave_addr, false);
    I2CMasterDataPut(I2C1_BASE, reg);
    //I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    while(!MAP_I2CMasterBusy(I2C1_BASE));
    while(MAP_I2CMasterBusy(I2C1_BASE));
    I2CMasterSlaveAddrSet(I2C1_BASE, slave_addr, true);
    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    while(!MAP_I2CMasterBusy(I2C1_BASE));
    while(MAP_I2CMasterBusy(I2C1_BASE));
    return I2CMasterDataGet(I2C1_BASE);

    Let me know if that adjust alone resolves the issue, or if there is more we will need to dig into to get this working as expected.

    Best Regards,

    Ralph Jacobi

  • Thanks for your prompt response.I tried above code in my software,but

    While(!MAP_I2CMasterBusy(I2C1_BASE));

    This command is not available in our driver library.it showing error. How can I solve this issue?

  • Hi Tom,

    Sorry abou tthat, I sent the code with the MAP API when you weren't using MAP calls for your provided code. Just remove the MAP_ from the front of the I2CMasterBusy APIs and it should compile fine. The MAP APIs are used to try and leverage that TivaWare APIs are in the ROM of the device but you need to add the right headers to use them which is what triggered the compile errors.

    Best Regards,

    Ralph Jacobi