Hi everyone,
I'm currently trying to integrate a peripheral with the CC2538 SoC using the i2c interface and ran into some difficulties to make it work properly.
Basically, one of the first problem seen is that the I2CM_DR register cannot be set. Also, I've found no documentation about the I2C Loopback Configuration which could be useful for test and debugging in order to test if the configuration was done properly.
I'm using the driverlib available through the Foundation Firmware V1.0.1.0 and the platform used is the SmartRF06 EB. Sadly, there are no examples available using the I2C interface. :(
To help a bit, here's the code used for the initialization:
// Ensure the peripheral is enabled
SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_I2C);
// Reset the peripheral to ensure clean state
SysCtrlPeripheralReset(SYS_CTRL_PERIPH_I2C);
// Config I/O pin A.6 to be I2C SCL
GPIOPinTypeI2C(GPIO_A_BASE, IOC_PIN_6);
IOCPinConfigPeriphOutput(GPIO_A_BASE, IOC_PIN_6, IOC_MUX_OUT_SEL_I2C_CMSSCL);
IOCPinConfigPeriphInput(GPIO_A_BASE, IOC_PIN_6, IOC_I2CMSSCL);
// Config I/O pin A.7 to be I2C SDA
GPIOPinTypeI2C(GPIO_A_BASE, IOC_PIN_7);
IOCPinConfigPeriphOutput(GPIO_A_BASE, IOC_PIN_7, IOC_MUX_OUT_SEL_I2C_CMSSDA);
IOCPinConfigPeriphInput(GPIO_A_BASE, IOC_PIN_7, IOC_I2CMSSDA);
// Init the i2c master clock in normal speed (SysClock = 32 MHz)
I2CMasterInitExpClk(SysCtrlClockGet(), FALSE); //I2CM_TPR = 0xF, MFE = 1
Afterwards, as a test to communicate with the device (external EEPROM), one operation tested was to send a word to it. The following code was used.
// Set slave address and RW reset to 0
I2CMasterSlaveAddrSet(slaveAddress, FALSE); // I2CM_SA set properly
// Verify that peripheral is ready
while(I2CMasterBusBusy()) // OK!
{
}
// Put the first byte to send. MSB first
I2CMasterDataPut((uint8)(data >> 8u)); // data = 0x091B -> I2CM_DR = 0!!
// Send the MSB to slave in burst mode since another byte comes after
I2CMasterControl(I2C_MASTER_CMD_BURST_SEND_START); // Don't send STOP until whole word sent, I2CM_CTRL = 0x3
// Wait until transfer is completed
while(I2CMasterBusy()) // I2CM_STAT = 0x4E -> Error!
{
}
Debugging was stopped after this point due to error. Otherwise, the next action was to send the LSB.
Another test was to try and read a byte from the EEPROM. Performing a read operation successfully populated the register I2CM_DR with the expected value 0xFF. Although there was an ADRACK error. But that could be an error on my side.
In conclusion,
1. Is there something missing with the configuration of the CC2538?
2. Is it normal that I2CM_DR cannot be set?
Thank you very much!
Sim