Other Parts Discussed in Thread: CONTROLSUITE, TMDSCNCD28035ISO
Hello TI experts.
I am having a problem with a slave device code. I am trying to communicate two f28035 via I2C. I managed to work write function but I cant read from slave device. I checked with oscilloscope and after the slave address slave sends nack and bus stucks at busy. How can I fix this? I used PMBus example from controlsuite. I will share the codes below.
MASTER SIDE
for(;;)
{
switch (command)
{
case WRITEWORD:
I2CMaster_Transmit(3, Master_TransmitBuffer, 0, 0);
break;
case READWORD:
while (I2CMaster_NotReady());
I2CMaster_Transmit(1, Master_TransmitBuffer, 2, Master_ReceiveBuffer);
break;
}
}
SLAVE SIDE
for(;;)
{
while(!I2caRegs.I2CSTR.bit.RRDY); //wait until data ready
command = I2caRegs.I2CDRR; //get the received data
StartCpuTimer0(); // Start the timer
switch (command)
{
case WRITEWORD:
while(!I2caRegs.I2CSTR.bit.RRDY); //wait for the data
Slave_ReceiveBuffer[0] = I2caRegs.I2CDRR; //get the lower byte of received data
StopCpuTimer0(); //No timeout, so stop the timer
ReloadCpuTimer0(); //Reload the period value (35 ms timeout)
while(!I2caRegs.I2CSTR.bit.RRDY); //wait for the data
Slave_ReceiveBuffer[1] = I2caRegs.I2CDRR; //get the upper byte of received data
break;
case READWORD:
while(!I2caRegs.I2CSTR.bit.XRDY);
I2caRegs.I2CDXR = Slave_TransmitBuffer[0];
StopCpuTimer0();
ReloadCpuTimer0();
while(!I2caRegs.I2CSTR.bit.XRDY);
I2caRegs.I2CDXR = Slave_TransmitBuffer[1];
break;
default:
break;
}
}