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.
Hi,
Master: MCP2221 microchip USB to i2c bridge. Driver is the standard MCP Linux driver. 100khz i2c bus speed.
Slave: MSP430F5308 @ 8mhz using the USCI peripheral and slightly modified TI sample code.
Test Equipment: LeCroy Scope with built in i2c bus analyzer. Ardvaark/Beagle TotalPhase I2c Packet Analyzer. Effective resistance on the i2c pullups is roughly 2K and the edges look nice and sharp at 100khz, with the i2c waveforms just over 0v and all the way up to 3.3v.
Problem: When the MCP2221 requests a Slave Transmit of a single 8 byte packet, there is no ACK clock generated by the MCP2221, causing the state machine to break on both sides. Speed 100khz I2c. 8mhz F5308 clock.
Analysis: After extensive troubleshooting, it appears that when the MSP430 is running at 8 mhz, it requires something in the neighborhood of 8us to respond to the incoming 7 bit address +R/W, and then to release the clock (ie - we think the 430 is stretching the clock), when it does release the clock for the MCP to initiate an ACK pulse, the MCP2221 doesn't react correctly and instead of sending the ACK, just starts clocking the Data word. We hypothesize the 8us is required by the 430 to process "is this address for me" and to interpret the R/W bit.
This only happens on a Slave Transmit, not a Slave write. When the clock speed of the MSP430 is increased to 16 or 24mhz, the MCP generates the ACK correctly and everything works normally. There was one observed condition with another programmers code also using the USCI, but on another family of MSP430, where the ACK pulse is 1/4 normal 100 khz pulse width, pointing us toward speeding up the MSP430 clock fixing the issue. This code was also fixed (ie - the clock pulse returned to normal width) by increasing the 430 code speed and further substantiates the clock stretching theory.
We ran some tests at higher clock rates on the MSP430 and if the clock speed is increased beyond 8mhz to say 16 or 24mhz, it appears that it takes less time to release the clock in roughly a time delay proportional to the clock speed increase. This allows greater i2c speeds, however is a workaround for the MCP2221 not accepting clock stretching correctly.
Of course we are working with Microchip to see if we can reprogram the driver of the MCP2221 to play nicer with clock stretching but in the mean time:
Questions:
1) Any idea why we see the problem on the Slave Transmit and not a Slave Receive?
2) Is the turnaround delay between the Address and the ACK dependent on purely on clock cycles on the MSP430 or is there RC/Analog/Propogation type delay we are dealing with.
3) Is there some setting or code we are missing that would make the MSP430 not insert a clock stretch delay between the R/W bit and the ACK (ie, can we speed up the time it takes for the 430 to release the bus on an I2c slave transmit ACK)?
Thanks! Blake
Hi Jace,
Basically, we are using something very close to the sample code setup routines:
UCB1CTL1 |= UCSWRST; // Enable SW reset, disable P4
UCB1CTL0 = UCMODE_3 | UCSYNC; // I2C Slave, synchronous mode
UCB1I2COA = SLAVE_I2C_ADDRESS;
UCB1CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
UCB1IE |= UCSTPIE | UCSTTIE | UCTXIE| UCRXIE; // Enable STT,STP,TX,RX interrupt
From a quick look at the family manual, the i2c clock appears to be selected by UCSSELx in the UCBxCTL1 register, which defaults to a 00 which seems to indicate UCLK. However, we are in Slave mode on the 430, and 38.3.5 says: "in slave mode, the bit clock generator is not used and the UCSSELx bits are don't care." I can set a 10b in UCSSELx if you think it might help (moving the clock to SMCLK), but it would appear it isn't used on the slave transmit (I hope I'm wrong as this would be a super easy fix).
Same issue with USCI35 as it looks like it just deals with master mode from what I can tell (and we are operating in slave mode).
Thanks for your help!
Blake,
I'm a little confused on the 8us figure here as that is as much time as a clock cycle of 100kHz I2C comms. Now the time it takes for the part to identify itself can be dependent on your part clock speed. Please see screen captures below. One of an MSP430F5529LP (same USCI module and clock system) slave transmit at 1MHz DCO and the other at 8MHz DCO. (With 100kHz clock, one cycle is ~9.5us on I2C line. @8MHz DCO, this time is stretched slightly to ~12us and at 1MHz DCO its stretched to ~60us.)
[8MHZ DCO]
**Attention** This is a public forum