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.

TM4C1231H6PGE: how to enable interrupt of NVIC of i2c 2 bus

Part Number: TM4C1231H6PGE

Hi ,

I am trying to enable the interrupt of the NVIC for the i2c 2 bus .

when i  do that , the bus is getting hanged not sure why .

below is the code to intialise the i2c2 help me out if am missing something

---------------------------------------------------------------------------------------------code------------------------------------------

    SysCtlPeripheralDisable(SYSCTL_PERIPH_I2C2);
    SysCtlPeripheralReset(SYSCTL_PERIPH_I2C2);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C2);

    // Enable and initialize the I2C master module Using the system clock.
    // The I2C transfer rate will always be 100kHz.
    //
    MAP_I2CMasterInitExpClk(I2C2_MASTER_BASE,  SysCtlClockGet(), false);
    //  MAP_I2CMasterGlitchFilterConfigSet(I2C2_MASTER_BASE, I2C_MASTER_GLITCH_FILTER_32);
    HWREG(I2C2_MASTER_BASE + I2C_O_MCR2) |= (6<<4); // Set to 16 clock glitch filter
    HWREG(I2C2_MASTER_BASE + I2C_O_MCR ) |= (1<<6); // and enable now
    //
    // Configure bus timeout to 25ms.  12-bit value for 25ms is 0x9C4 (2500
    // clocks), so round upper 8 bits to 0x9C.  Each clock is 10us since
    // 100kHz I2C is required for CiscoI2C.
    //
    MAP_I2CMasterTimeoutSet(I2C2_MASTER_BASE, 0x9C);

    MAP_I2CMasterIntEnableEx(I2C2_MASTER_BASE, I2C_MASTER_INT_DATA | I2C_MASTER_INT_TIMEOUT);
 
    ROM_IntEnable(INT_I2C2);
-----------------------------------------------------------------------------------------------------------------------

this particular function in the code is causing the issue.

 
    ROM_IntEnable(INT_I2C2);

Thanks,

Rohith

  • Hello Rohith,

    Do you have the master interrupt enable being called too? I am not sure if there is more code than you are showing me, but you need this API as well:

        ROM_IntMasterEnable();
    

  • Hi Ralph,

    Thanks .

    This line of the code refers to the ROM_IntMasterEnable :

    MAP_I2CMasterIntEnableEx(I2C2_MASTER_BASE, I2C_MASTER_INT_DATA | I2C_MASTER_INT_TIMEOUT);

    It is called before the ROM_IntEnable(INT_I2C2)

    Thanks,

    Rohith.

  • Hello Rohith,

    That API enables the interrupts as an I2C Master, and it is specific to the I2C peripheral.

    That is not the MCU wide interrupt enable.

    ROM_IntMasterEnable(); is not specific to I2C but rather it enables the NVIC for MCU as a whole.

  • Hi Ralph ,

    Thanks for your quick response .

    The similar code is used for intializing the other i2c buses (i2c 1 and i2c 3 bus )used to drive various slave devices .

    When I am trying to do the same thing for the i2c 2 bus , I am facing the issue .

    Y it is so ..it is connected to PF7 And PF6 of MCU , do these pins have any limitations with respect to the functioning.

    Thanks ,

    Rohith.

  • Hello Rohith,

    You are probably going to need to share the code you are using for the other I2C's for me to comment on what is different, but one idea I can think of without looking at the code is that you didn't add your ISR to the startup_ccs.c file. If you debug, pause and see if you are in the DefaultIntHandler. If so your ISR isn't linked right.