Other Parts Discussed in Thread: TMS320F28035
I have an implementation for I2C for the TMS320F28035. I had everything working for communication, had to make some setup changes with hardware and now the 28035 no longer communicates over the bus. I just want to verify that my code is correct.
I am seeing the SCL line go line once the command register is set but it never comes back high again for a new cycle.
static void InitI2CGpio()
{
EALLOW;
SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;
// Enable pull-ups for I2C pins
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 1;
// Asynchronous input selection
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3;
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3;
// Configure pin operation
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // SDA
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // SCL
EDIS;
}
void I2CInit()
{
InitI2CGpio();
I2caRegs.I2CMDR.bit.IRS = 0; // Reset the I2C module
I2caRegs.I2CPSC.all = 5; // Prescaler - need 7-12 Mhz on module clk
I2caRegs.I2CCLKL = 5; // Allow more time when clock is low
I2caRegs.I2CCLKH = 5; // Need less time when clock is high
I2caRegs.I2CIER.all = 0; // Disable interrupts
I2caRegs.I2CFFTX.all = 0; // Disable FIFO mode and TXFIFO
I2caRegs.I2CMDR.bit.IRS = 1; // Take I2C out of reset
}
WORD I2CWrite(I2C_MESSAGE_T* message)
{
WORD status = I2C_SUCCESS;
// Setup slave address
I2caRegs.I2CSAR = message->SlaveAddress;
// Setup number of bytes to send
I2caRegs.I2CCNT = message->NumberOfBytes;
for(WORD i = 0; i < message->NumberOfBytes; i++)
{
I2caRegs.I2CDXR = *(message->DataBuffer + i);
}
// Send start as master transmitter
I2caRegs.I2CMDR.all = 0x2E20;
return status;
}