Hi Mark,
I'm trying to debug some IIC problems. My Hardware has two IIC devices a TC665 Fan controller and a PCF8575 16 bit IO expander, I've added these chips to the Simulator and it all seems to work fine. On the real hardware I have been testing the integrity of the IIC by changing the FAN speed in response to a button push. Using the following Commands
static const unsigned char IIC_WrTC665_FanSlow[] = {0x36, 0x06, 0x00}; // {address, register, data}
static const unsigned char IIC_WrTC665_FanFast[] = {0x36, 0x06, 0x0f}; // {address, register, data}
static const unsigned char IIC_WrTC665_FanSpeed[] = {0x36, 0x07}; // {address, register, data}
static const unsigned char IIC_RdTC665_FanSpeed[] = {2, 0x37, OWN_TASK}; // {address, register, data}
static const unsigned char IIC_Rd8575[] = {2, 0x41, OWN_TASK}; // {bytes, address, TASK_TO_WAKE}
static const unsigned char IIC_Rd8575_1[] = {1, 0x41, OWN_TASK}; // {bytes, address, TASK_TO_WAKE}
static const unsigned char IIC_Rd8575_2[] = {2, 0x41, OWN_TASK}; // {bytes, address, TASK_TO_WAKE}
static const unsigned char IIC_Rd8575_3[] = {3, 0x41, OWN_TASK}; // {bytes, address, TASK_TO_WAKE}
I start the IIC interface using the following
static void fnConfigIIC_Interface(void)
{
IICTABLE tIICParameters;
tIICParameters.Channel = 0;
tIICParameters.usSpeed = 100; // 100k
tIICParameters.Rx_tx_sizes.TxQueueSize = 64; // transmit queue size
tIICParameters.Rx_tx_sizes.RxQueueSize = 64; // receive queue size
tIICParameters.Task_to_wake = 0; // no wake on transmission
if ((IICPortID = fnOpen( TYPE_IIC, FOR_I_O, &tIICParameters)) !=0) { // open the channel with defined configurations
fnWrite(IICPortID, (unsigned char *)&IIC_WrTC665_FanSlow, sizeof(IIC_WrTC665_FanSlow)); // set the fan speed
fnRead(IICPortID, (unsigned char *)&IIC_Rd8575, 0); // start the read process of 16 bytes
}
}
I get a write to the Fan as expected, followed by a read from the 8575 chip, but a logic analyser shows 3 bytes being read not 2 as expected.
I can write as much as I want to the Fan chip, but as soon as I try another read of the 8575 chip using fnRead(IICPortID, (unsigned char *)&IIC_Rd8575, 0); only one byte is returned and the IIC bus seems to lock up.
I've documented my findings in the attached document, which has the logic analyser traces.
It seems that uTasker is trying to read 1 more byte than requested, and that only reading 1 byte seems to lockup the IIC driver.
Do you have any thoughts?
Cheers
Martin