Hi Gregory,
I have checked your code.
Here is the first reason for the code not runs properly:
The IIC module on the RX site can held the bus in "Busy" state after power-ON event. So the best way is first to check the bus state. Here is the example which I have used for this task:
void Test_IIC_Bus(void)
{
if((IIC1S_BUSY) || (IIC1S_ARBL)) WaitNms(5);
if((IIC1S_BUSY) || (IIC1S_ARBL)) WaitNms(5);
if((IIC1S_BUSY) || (IIC1S_ARBL)) WaitNms(5);
if((IIC1S_BUSY) || (IIC1S_ARBL)) Reset_IIC();
}
When the bus is "locked" in the busy state by slave device, it has to be used the "IIC Reset" function. See example:
void Reset_IIC(void)
{
IIC1C_IICEN = 0; // Disable IIC;
SCL = 1;
Wait_sh(10);
SDA = 0;
Wait_sh(10);
for(i=0;i<9;i++)
{
SCL = 1;
Wait_sh(10);
SCL = 0;
Wait_sh(10);
}
SCL = 1;
Wait_sh(10);
SDA = 1;
IIC1C_IICEN = 1; // Enable IIC;
Wait_sh(20);
}
This routine sends START bit, 9 SCL clocks with no data (SDA = 0) and then STOP bit. This sequence resets all connected slaves on the IIC bus. Then the bus is ready to use.
The second reason:
The MST bit has to be cleared in the IIC_Init() function. When the MST goes from 0 to 1 it bit generates the START condition on IIC bus. Then the slave expects the SCL clocks with such address and R/W command on SDA line.
So please make corrections in your code in accordance to my examples. As the first step use such simple Slave device (e.g. IIC EEPROM) to debug the master side of your code. The good guide could be the AN3291 also. You can use copy/paste for that code example, because IIC modules are the same in GB60 and AW60 MCUs.
I hope it can help you, but send me please the message with result.
Best Regards,
Stano.