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/EK-TM4C1294XL: Failed to assign a none zero value to the I2C register I2C_O_MCLKOCNT

Part Number: EK-TM4C1294XL

Tool/software: Code Composer Studio

Hi, Expert

    I am writing a code regarding I2C, to configure the timeout function, I need to write a none zero value to this register, but I found what ever the value I tried to write into register, I always read 0 back from the same register.

   The offset is defined with macro I2C_O_MCLKOCNT which is with the offset 0x24 from the base address of 0x40020000, the RCGCI2C register has been assigned with the value of 1, and the RCGCGPIO has also been assigned as 2.

   The initialize code is listed as below

void SMBusInit()
{
    uint32_t u32Counter;
    //
    // Enable the clocks to the I2C and GPIO modules.
    //
    HWREG(SYSCTL_RCGCGPIO) |= (I2C_SCLPIN_CLOCK_ENABLE |
                               I2C_SDAPIN_CLOCK_ENABLE);
    HWREG(SYSCTL_RCGCI2C) |= I2C_CLOCK_ENABLE;
    HWREG(I2C0_BASE + I2C_O_MCLKOCNT) = 0x7d;
    //
    // Configure the GPIO pins for hardware control, open drain with pull-up,
    // and enable them.
    //
    HWREG(I2C_SCLPIN_BASE + GPIO_O_AFSEL) |= I2C_CLK;
    HWREG(I2C_SCLPIN_BASE + GPIO_O_PCTL) |= I2C_CLK_PCTL;
    HWREG(I2C_SCLPIN_BASE + GPIO_O_DEN) |= I2C_CLK;
    HWREG(I2C_SCLPIN_BASE + GPIO_O_ODR) &= ~(I2C_CLK);
    HWREG(I2C_SCLPIN_BASE + GPIO_O_PUR) |= I2C_CLK;

    HWREG(I2C_SDAPIN_BASE + GPIO_O_AFSEL) |= I2C_DATA;
    HWREG(I2C_SDAPIN_BASE + GPIO_O_PCTL) |= I2C_DATA_PCTL;
    HWREG(I2C_SDAPIN_BASE + GPIO_O_DEN) |= I2C_DATA;
    HWREG(I2C_SDAPIN_BASE + GPIO_O_ODR) |= I2C_DATA;
    HWREG(I2C_SDAPIN_BASE + GPIO_O_PUR) |= I2C_DATA;

    I2CMasterInitExpClk(I2C0_BASE, DEFAULT_I2C_CLK_RATE, false);
    I2CMasterTimeoutSet(I2C0_BASE, 0X7D);               //0X7D for 20ms delay timeout for 100kHz SCLK
    u32Counter = HWREG(I2C0_BASE + I2C_O_MCLKOCNT);
    HWREG(I2C0_BASE + I2C_O_MCLKOCNT) = 0x7d;
    u32Counter = HWREG(I2C0_BASE + I2C_O_MCLKOCNT);
    I2CIntRegister(I2C0_BASE, SMBusInterruptHandler);
    I2CMasterIntEnableEx(I2C0_BASE, I2C_MASTER_INT_NACK | I2C_MASTER_INT_DATA | I2C_MASTER_INT_TIMEOUT );
    HWREG(I2C0_BASE + I2C_O_MCLKOCNT) = 0x7d;
    u32Counter = HWREG(I2C0_BASE + I2C_O_MCLKOCNT);
}

   Please can you help to comment what else I still need to configure before I sent the value of MCLKOCNT register?