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.

TMS570LC4357: Understanding TI I2C Bus

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN,

Hi

1. I would like to use interrupt mode for the i2c bus. I activate the interrupt using halcogen. See img below. Does it mean that I can't use polling of those bits? Would it work if I use polling? There are so many supplied routines by Halcogen that uses polling'

2. I would like to detect the functioning of my i2c bus and my i2c devices before I start to call i2cSendByte(i2c, cmd) or i2cReceiveByte(i2c). How to detect it? The reason is because I find that once I call any of the i2c send or receive routines, if the bus is non functioning, the software will hang in the polling of I2C_RX_INT and I2C_TX_INT. Bad pcbs and devices are common but software should not hang polling. 

eg

while ((i2c->STR & (uint32)I2C_RX_INT) == 0U)
{
} /* Wait */

3. Please help to check following code. I want to use it to check if it can trigger an interrupt. Alas because it only send the i2c address and no data, there is no interrupt generated. To make matters worse, there is no stop bit generated. The routine hangs in the polling of stop bit. Thank you for your support.

  • Hi LayEng,

    1. I would like to use interrupt mode for the i2c bus. I activate the interrupt using halcogen. See img below. Does it mean that I can't use polling of those bits? Would it work if I use polling? There are so many supplied routines by Halcogen that uses polling'

    Yes, you can use status bits to poll irrespective of interrupt enable, the status bits will get set whenever the corresponding condition happens on i2c bus irrespective of interrupt enable status.

    I would like to detect the functioning of my i2c bus and my i2c devices before I start to call i2cSendByte(i2c, cmd) or i2cReceiveByte(i2c). How to detect it? The reason is because I find that once I call any of the i2c send or receive routines, if the bus is non functioning, the software will hang in the polling of I2C_RX_INT and I2C_TX_INT. Bad pcbs and devices are common but software should not hang polling.

    Bus Busy(BB) bit will indicate the status of i2c bus, this bit will get SET if an i2c bus was busy.

    If we try to send data even if the i2c bus was busy, in that case Arbitration lost flag will get SET.

    --

    Thanks & regards,
    Jagadish.

  • Dear Jagadish

    Thank you for your reply.

    If you look at this code below, you will find that bus busy check comes after receive byte. How to check it before to prevent hanging in receive byte for non functioning device or i2c bus. I actually have a board whereby the i2c interrupts don't work at all. That is one case. Another case is if the device don't work. Hence I tried to use item 3 above whereby i make i2cSetCount(i2c, 0) . I set count =0 so I don't need to transmit or receive data. Just test the slave address.  But then the stop bit don't work after sending the slave addr. What do you recommend. Currently the software only work if my bus and devices work but hangs if either one don't work. The software should be able to detect the failure and not perform the i2c transaction for failed bus or device. Looking forward to your support. Thank you

  • Dear Jagadish

    I will close the other case about sample code. The sample code only work for working bus and working devices but not when there are problems. I will continue asking you on this thread. 

  • Hi LayEng,

    I don't think it would be required to check i2c busy bit before receiving a byte, it is because there won't be any multi masters on the bus right. I mean there is only a single master that initiates the start condition and sends the slave address so there won't be any possibility to get SET busy flag before receiving a byte.

    If you still want to check before sending start byte also then you can do something like below

    --

    Thanks & regards,
    Jagadish.

  • Dear Jagadish

    Thank you for your reply. I will see if your suggestion works for defective boards and ICs. Can I ask you about my code which I pasted above under item 3. I paste below again. Can you try this code on your side and see if it works for detecting any IC? I have used it on my side and find that there is no stop bit sent. Hence the code will fail at while loop for checking stop bit. Looking forward to your reply. Thank you

  • FYI, I have 4 or 5 bad boards with defective i2c devices./buses. I have to comment out i2c for these boards. Only 1 working boards. How can my sw be released for production?

  • Hi LayEng,

    Can I ask you about my code which I pasted above under item 3. I paste below again. Can you try this code on your side and see

    Just now i started working on your code and i will provide an update by tomorrow.

    I have 4 or 5 bad boards with defective i2c devices./buses.

    Are you saying board with our TI controller is defective?

    --

    Thanks & regards,
    Jagadish.

  • Dear Jagadish

    I have 4 defective pcb modules using TMS570LC4357 out of 5. The defective modules have non functioning i2c bus as in when I use while loops instead of interrupts for transmitting and receiving data, the software will hang in the while loops. I eventually found a fifth board and using interrupts instead of while loops for transmitting and receiving, it works. Base on this method, I was able to determine that the software is able to detect correctly even if the slave device is not working. Everything seems fine now. I have the following questions:

    1. How do I select the interrupt method prior to compiling? Is it when I select the i2c interrupts during halcogen as in the image below? Which register should I set if I don't use halcogen/

    2. Please look at the software below.

    IC LTC2991_I2C_ADDR is not working or absent. When the i2cReceive(i2c, length, RX_Data); is executed, it enters the interrupt arm of the i2cReceive routine. I would like to know when this interrupt occurs as the IC is not present. Which software trigger the interrupt?

    Looking forward to your reply. Thank you

  • By the way, the while BB check which you recommend doesn't work to prevent the software from entering into i2c routines if the i2cbus is not working.

  • Hi LayEng,

    I have 4 defective pcb modules using TMS570LC4357 out of 5. The defective modules have non functioning i2c bus

    I don't think it could possible. 4 out of 5 devices defective i2c.

    Maybe we are doing something wrong, some user mistake.

    The problem is i don't have the slave device you are mentioning.

    We will do one thing, lets setup a meeting so that i could see the issue you are mentioning directly.

    My available timings: 10AM to 7PM IST.

    --

    Thanks & regards,
    Jagadish.