Hello,
is the Halcogen I2C driver capable of detecting NACK from missing slaves?
If I use i2cSend and the slave is not connected, then the function hangs at:
while ((i2c->STR & (uint32)I2C_TX_INT) == 0U){};
Best regards,
Thomas
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Thomas,
I've contacted the Halcogen team to ask them to have a look to your problem.
Hi Thomas,
Not sure what you mean with Arbitration Loss problem.
Please have a look at SPRU175. I find, that this document is very helpful when it comes to implementing a I2C driver for the HW module used on Hercules.
As per description in SPRU175 arbitration loss means, that two masters tried to transmit at the same time. I would guess that a way to handle this is to retry transmission after a certain time, like it is done in the CAN protocol. However, the I2C module can't resolve this by it's own.
To my mind this is an application defined behaviour and thus has to be handled in you I2C communication driver not in the HALCoGen low level routines.
Best Regards,
Christian
Hi Thomas,
The code that I posted here uses repeated start conditions to read multiple bytes from a slave.
/* Transmit Repeated Start condition */
You don't need to call i2cInit before every transmission as long as the transmission was correctly terminated, which my code should do.
Best Regards,
Christian
Hi Thomas,
Have you tried/looked at the Example example_i2cMaster_TX_RX.c and example_i2cSlave_TX_RX.c that comes with HALCoGen 4.04.xx ? This is basically 2 board example in which one Hercules board acts as master which contains example_i2cMaster_TX_RX.c and other board example_i2cSlave_TX_RX.c is loaded and that acts as Slave.
Hello Prathap,
my code bases on the examples.
But there is also no repeated start example.
I have to write the control register address to a slave and a second master is writing an other address to the slave.
Hi Thomas,
HALCoGen 4.04.00 Example example_i2cMaster_TX_RX.c is a repeated Start example. For Start condition is set for every 10 Bytes of Data TX or RX.
As per example
Master first does 2 * 10 bytes TX.
Master sets Start condition, does 10 Bytes of Data TX, Again sets Start condition, does 10 Bytes of Data TX.
Then Master does 2 * 10 bytes RX
Master sets Start condition, does 10 Bytes of Data RX, Again sets Start condition, does 10 Bytes of Data RX.
Probably I am not getting your problem exactly. If you have faced a Arbitration lost in your master, you must clear the flag and re initiate the transfer right from setting the Mode to master, stop bit, then start bit etc... like in the example file...
----
----
/* Set mode as Master */
i2cSetMode(i2cREG1, I2C_MASTER);
/* Set Stop after programmed Count */
i2cSetStop(i2cREG1);
/* Transmit Start Condition */
i2cSetStart(i2cREG1);
----
----