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.
I'm using UCB1 in 400kHz I2C master mode, and after a few bytes are read, the I2C engine appears to hang with the busy bit set. If you look at the SCL line on a scope, you can see 400kHz SCL pulses going on forever. If I remove the external device so that nothing is on the bus, the pulses continue, so the pulses are coming from the MSP430.
This doesn't seem to happen with write transactions or with 100kHz I2C. I can't think of a reason why the bus would get stuck in this state. Any suggestions for debugging this issue? Any experiments I should run or data I should collect?
Thanks,
Michael
Hello Michael,
If the MSP430 is the master, then the SCL line is controlled by the MSP430. The slave device could hold it low aka clock stretching. when these clock pulses happen, are they in TX mode or RX on the MSP430? If its TX mode, then you are filling the TXbuf repeatably. If you are receiving then its possible that a STOP was not properly sent and you are still reading the RXbuf as the MSP430 will stall the I2C if the RXbuf is not read in time. I can see a scenario if you are running the CPU really slow and your I2C fast, you could get in a loop (depending on external logic) of trying to always receive. without checking receive count in time and sending a STOP. Usually when I2C gets off track, the bus is stalled or idled (communication stop).
I would also suggest looking at the following application note to debug further.
Solutions to Common eUSCI and USCI Serial Communication Issues on MSP430 MCUs
Jace,
To be clear, the bus isn't stalled with SCL held low- it is continuously pulsing at 400kHz.
You are correct that I am using an interrupt to generate the stop condition. The number of receives is known ahead of time, so the RX ISR is decrementing a counter and setting TXSTP whenever the counter reaches 1 (which means the last byte is currently in progress). The RX interrupt flag is being cleared, but the RX interrupt is not being disabled. I can try that. I'll also check in the debugger if any UCB1IFG bits are set. I do know that TXSTP is set when I look at the control register in the debugger, so I've at least went through the code path to transmit a stop.
Unfortunately I have not yet had a chance to test it out as I have been busy with other things. I hope to get to it next week.
Checking this out again, I've tried adding an interrupt disable. However, the issue occurs before I finish receiving enough bytes, so it doesn't really make a difference. I'm doing a 2-byte read and the MSP430 (master) is NACKing the first byte back it's reading and then continuously pulsing SCL. No USB1IFG bits are set, and UCB1STAT is 0x10 (busy only). UCB1CTL0 = 0x2F and UCB1CTL1 = 0x80 (UCSSEL_2).
**Attention** This is a public forum