I am using the following:
Tiva TM4C1294NCPDT CPU
CCS 6.1.2 using
TIRTOS 2.16.0.08,
compiler 5.2.7 and
XDC 3.31.1333
I am using the I2C0 module and I have everything working but sometimes I get the I2C bus to hang and I can recover the I2C with a CPU soft reset but I want to see if I can get the I2C bus to recover by soft resetting just the I2C0 module in the Tiva so I tried the following….
The Code I use for initial setup is:
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
GPIOPinConfigure(GPIO_PB2_I2C0SCL); // clock B2
GPIOPinConfigure(GPIO_PB3_I2C0SDA); // data B3
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
I2C_init();
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_100kHz;
i2c_Handle = I2C_open(0, &i2cParams);
I2C_transfer(i2c_Handle, &i2cTransaction); This is the write that normally works.
***************************************************************************
When the I2C bus hangs, I tried the following to reset just the I2C bus but so far without success:
I2C_close(i2c_Handle); // Close it
Task_sleep(10);
SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); // Reset the I2C device
Task_sleep(10);
SysCtlPeripheralDisable(SYSCTL_PERIPH_I2C0); // disable the I2C device
Task_sleep(10); // delay
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); // re-enable the I2C device
// re-configure everything as before.
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
GPIOPinConfigure(GPIO_PB2_I2C0SCL); // clock B2
GPIOPinConfigure(GPIO_PB3_I2C0SDA); // data B3
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
I2C_init();
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_100kHz;
i2c_Handle = I2C_open(0, &i2cParams);
I2C_transfer(i2c_Handle, &i2cTransaction);
If the I2C bus was hung, this does not fix it but a soft reset does. Is there something more I can do to soft reset just the I2C module and not the CPU to recover the I2C operations??