Talk:I²C
This is the talk page for discussing improvements to the I²C article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
Computing C‑class Mid‑importance | ||||||||||
|
Nonsense
"Buses of this type became popular when ??? realized that much of the expense of an integrated circuit results from the size of the package and the number of pins." There's a noun missing in this sentence, and I'm not sure what it's supposed to be --Jsnow 21:27, 6 May 2005 (UTC)
- Some anon deleted the word "engineers". - Omegatron 21:54, May 6, 2005 (UTC)
- If much of the cost of an IC is really the packaging why do even the lowest pin count pics cost far more than basic logic chips? Plugwash 23:44, 7 October 2006 (UTC)
- Maybe they don't mean the cost of chip manufacturing, but the cost of using it on a PCB? Large size, etc. — Omegatron 02:11, 8 October 2006 (UTC)
- If much of the cost of an IC is really the packaging why do even the lowest pin count pics cost far more than basic logic chips? Plugwash 23:44, 7 October 2006 (UTC)
Would it not be better to say "clock frequencies down to 0Hz" rather than "down to DC"? It may be the same thing, but DC is not usually used to refer to clock frequency. —Preceding unsigned comment added by 146.232.75.208 (talk) 13:19, 5 April 2008 (UTC)
- Sure, now says "arbitrarily low clocks" 69.226.236.175 (talk) 22:53, 26 August 2009 (UTC)
- No, 0Hz could mean 0 Volt for an eternity, which would starve the device 130.89.167.48 (talk) 20:14, 24 October 2010 (UTC)
Synonyms
I'm not sure how to do it but could someone else edit the page so that if "2-wire serial" or similar is searched for then this page comes up? FzerozeroT 21:25, 14 November 2006 (UTC)
- I think it can be done, whilst another 2-wire interface wouldn't be presented (then 2-wire serial, 2-wire redirects should be replaced by disambig). --Yuriy Lapitskiy 06:20, 15 November 2006 (UTC)
The same should be the case for TWI (Two Wire Interface) which some uC makers prefer to call the famliy of busses. 81.215.13.145 13:05, 19 February 2007 (UTC)
Pronounciation
Is there a reference which says "eye-too-see" is incorrect prounouciation? --Cowbert 22:55, 27 December 2006 (UTC)
- How about the converse: can you find a source that says it is correct? Everywhere I look it says "squared" not "two". If there is no de jure pronunciation then the de facto pronunciation is eye-squared-see; I have never heard it said eye-two-see for that matter. Cburnett 23:47, 27 December 2006 (UTC)
- Fine, but the article asserts that "I-two-C" is incorrect. The burden of proof for actually making an assertion is higher than observing an absence of proof to the contrary. I have no problem with the article stating that "eye-squared-see" is the de-facto pronounciation; anon_user back on 29 Nov 2006 added the "also, incorrectly..." clause, without a reference. --Cowbert 01:18, 29 December 2006 (UTC)
- Except eye-two-see is incorrect pronunciation by the mere fact that virtually no one says it. Do a google search to see my point. "eye-two-see" gets 1 hit. "I-squared-C" gets 582 hits. "I-two-C" gets 4 hits. When something is widely true, so true that no source is going to assert it then you can't source it. You're not going to find a source saying that "bob" is pronounced "pop" (a bit hyperbolic, perhaps, but illustrates my point). I do welcome any suggestions on how to deal with this. If it has to be reworded to be less authoritative, then so be it. At the end of the day "eye-two-see" is incorrect though... Cburnett 01:41, 29 December 2006 (UTC)
- As a counterpoint, I would wager that most anyone assuming the I-two-C pronunciation would not explicitely spell out the pronunciation on a webpage. After all, it is commonly spelled "I2C", not "I^2C" or "I²C" when not typeset. You only need to say "I-squared-C" when arguing that is is pronounced differently than it looks. I would still like to see an authoritative source that I-two-C is absolutely incorrect. The superset two doesn't mean a lot, since it has been used in other electronics (e.g. Odyssey²) to mean "two". I have indeed heard it it called I-two-C in electronics labs before. --141.212.106.126
- While Phillips engineers pronounce it "eye-squared-see", many end users do indeed pronounce it "eye-two-see", regardless of Google hits (I work for a company that specializes in I2C). AFAIK Phillips does not specify the correct pronunciation - but when you consider that the only reason the pronunciation of "eye-two-see" abounds is because of the difficulty of printing the "squared" symbol and ignorance that it is indeed a "squared" and not a "two", I think it's fair to say that "eye-too-see" is incorrect. Phillips won't take away your slave address license for saying "eye-two-see" :) but they will repeat it back to you as "eye-squared-see". --Intx13 21:57, 31 July 2007 (UTC)
- For what it's worth, I've never heard anyone say anything *but* "eye-two-see" when talking. It's often written that way, what with superscripts being as hard to type as to pronounce. Google search returned 2.7 million for "i2c", barely 140 thousand for I²C... I count the latter as a pedantic path, understood but rarely used in practice. 69.226.236.175 (talk) —Preceding undated comment added 23:06, 26 August 2009 (UTC).
- Actually, it's pronounced minus-one-see. But seriously, it means "inter-intergrated-circuit", so if eye-squared-see is incorrect, it would have been called 2IC.130.89.167.48 (talk) 20:20, 24 October 2010 (UTC)
- Also for what it's worth I've always said and heard "two". More generally is there a standard for double letters in acronyms? Saying squared does not seem like an appropriate way to denote two of something. — Preceding unsigned comment added by Asdf39 (talk • contribs) 01:44, 11 October 2011 (UTC)
Proposal: Addition of I2C-RAM
Also I2C-RAMs are available, for instance the PCF8570 (Philips). It is helpful for communication between processors or controllers. —Preceding unsigned comment added by 80.156.43.1 (talk) 17:29, 30 October 2007 (UTC)
Basic values
It should be noted somewhere the default values for circuits - for example, the Rp is usually 4.7 kohms
- They vary widely. I just checked one board I have; 2.2K for some, and 47K (! not 4.7K !) on another branch of the tree. Don't think we can give values like that; they're circuit dependent. See the relevant specs. 69.226.236.175 (talk) —Preceding undated comment added 23:10, 26 August 2009 (UTC).
Licensing
The articale states "As of October 1, 2006, no licensing fees are required to implement the I²C protocol". I'd be interested to know about licencing terms Philips used to require. I seemed to remember that you could implement the bus logic, just not call your device "i2c compatible" unless you wrote a cheque. Anyone know more on this ? Whenrybruce (talk) 23:16, 3 November 2008 (UTC)
- I believe i2c as a term was trademarked but the interface technique itself wasn't. Thus you'd have companies developing the exact same thing and calling it "two wire interface" among others. Intel developed their own version of i2c, changed the voltages, and called it smbus. —Preceding unsigned comment added by 150.135.210.16 (talk) 01:21, 29 October 2010 (UTC)
Propose removing "Example of bit-banging the I2C Master protocol"
There is a whole page of code dropped in, with no context and no explanation why it is important. Furthermore it has a lot of undefined functions (I assume some sort of library is used). And it disrupts the article. It's a good faith addition, but WP is not an instruction manual (WP:NOTMANUAL) for lots of reasons, e.g. the code cannot be ascertained to be good. I propose deleting it. Adpete (talk) 00:36, 2 February 2011 (UTC)
- Your are fast : only one day after the proposal the section is removed. I suggest you remove the same section in the SPI wikipedia section.
- What don't you interstand in the code ?
- The code is only a template (like spi one), it isn't the full code.
- Why it is usefull ? Because it helps understand how i2c realy work. And it is an illustration of all the concept explain earlier (start/stop bit, clock stretching, ack/nak, ...)
unsigned start = 0;
unsigned read_bit(void)
{
unsigned bit;
/* Let the slave drive data */
READSDA();
I2CDELAY(I2CSPEED/2);
/* Clock stretching */
while (READSCL() == 0);
/* SCL is high, now data is valid */
bit = READSDA();
I2CDELAY(I2CSPEED/2);
CLRSCL();
return bit;
}
void write_bit(unsigned bit)
{
if (bit) {
READSDA();
} else {
CLRSDA();
}
I2CDELAY(I2CSPEED/2);
/* Clock stretching */
while (READSCL() == 0);
/* SCL is high, now data is valid */
/* If SDA is high, check that nobody else is driving SDA */
if (bit) {
if (READSDA() == 0) {
ARBITRATION_LOST();
}
}
I2CDELAY(I2CSPEED/2);
CLRSCL();
}
void start_cond(void)
{
if (start) {
/* set SDA to 1 */
READSDA();
I2CDELAY(I2CSPEED/2);
/* Clock stretching */
while (READSCL() == 0);
}
if (READSDA() == 0) {
ARBITRATION_LOST();
}
/* SCL is high, set SDA from 1 to 0 */
CLRSDA();
I2CDELAY(I2CSPEED/2);
CLRSCL();
start = 1;
}
void stop_cond(void)
{
/* set SDA to 0 */
CLRSDA();
I2CDELAY(I2CSPEED/2);
/* Clock stretching */
while (READSCL() == 0);
/* SCL is high, set SDA from 0 to 1 */
if (READSDA() == 0) {
ARBITRATION_LOST();
}
I2CDELAY(I2CSPEED/2);
start = 0;
}
unsigned tx(int send_start, int send_stop, unsigned char byte)
{
unsigned bit;
unsigned nack;
if (send_start) {
start_cond();
}
for (bit = 0; bit < 8; bit++) {
write_bit(byte & 0x80);
byte <<= 1;
}
nack = read_bit();
if (send_stop) {
stop_cond();
}
return nack;
}
unsigned char rx (int nak, int send_stop)
{
unsigned char byte = 0;
unsigned bit;
for (bit = 0; bit < 8; bit++) {
byte <<= 1;
byte |= read_bit();
}
write_bit(nak);
if (send_stop) {
stop_cond();
}
return byte;
}
Well it's certainly no use to me. It's too long to read easily. Yes I can see functions start_cond and stop_cond, but since they are explained far far better in the above diagram, what's the point? As far as I can see, all it is doing is converting a byte to serial, and then sending/receiving it using the I2C protocol. Do we really need a page+ of code just to illustrate that? And how do we know the code works? Where is the reference? But most crucially, Wikipedia is not a technical manual. Its job is to describe I2C, not teach it. Adpete (talk) 10:58, 16 February 2011 (UTC)
- No answer to these objections, so I'll delete it in the next day or two. Adpete (talk) 23:47, 10 March 2011 (UTC)
- Hi! I found this code example immensely useful since it puts in concrete terms (for me, a programmer) what you have to do *and* provided me with a working implementation, which I used. An example is worth a thousand words. However, I suspect it needs correcting in that it doesn't respect the stop bit setup time, with a minimum of 4us (I2C spec UM10204, table9 / figure 27, pp37-38, t(SU:STO)), but instead raises SDA immediately after raising SCL with no delay. Can someone confirm this? 94.165.237.104 (talk) 13:56, 22 September 2011 (UTC)
void i2c_stop_cond(void)
{
/* set SDA to 0 */
CLRSDA();
I2CDELAY();
/* Clock stretching */
while (READSCL() == 0)
; /* You should add timeout to this loop */
+ /* Stop bit setup time, minimum 4us */
+ I2CDELAY();
/* SCL is high, set SDA from 0 to 1 */
if (READSDA() == 0)
ARBITRATION_LOST();
I2CDELAY();
started = false;
}
- Sorry, forgot to log in... The same goes for the repeated start condition, which has a 4.7us setup time. Martinwguy (talk) 15:22, 22 September 2011 (UTC)
void i2c_start_cond(void)
{
if (started) {
/* set SDA to 1 */
READSDA();
I2CDELAY();
/* Clock stretching */
while (READSCL() == 0)
; /* You should add timeout to this loop */
+ /* Repeated start setup time, minimum 4.7us */
+ I2CDELAY();
}
...
There seems to be a more professional code example, respecting all the right delays from the spec, here: http://www.maxim-ic.com/app-notes/index.mvp/id/4267 -> "Proven Implementations for Bit-Banging I²C" -> I2C_bit_bang_c.zip Martinwguy (talk) 15:22, 22 September 2011 (UTC)
Code example cleared up
I just made an edit to the code comments, to clarify what the macros do. That's because there is no SETSDA() or SETSCL() macros. The original coder assumed that the READSDA() and READSCL() macros could be used for this purpose, but did not clarify that for this to work, the macros must first set the pin to an input, to allow the signal to be pulled high by the external resistors.
I have made the simplest change to make this more clear, but a more clear change would be to add SET* macros, which are separate in purpose to the READ* macros.
As for the previous discussion about the usefulness of this code and whether it belongs on the page at all, I'd like to comment that it was useful me, and should stay..... I confirm the reading and writing of single bytes works. (Arbitration and restarts untested but look good.) — Preceding unsigned comment added by Gibster777 (talk • contribs) 09:27, 11 April 2011 (UTC)
The example code in article claims to be C, but is "pseudo" C because of the "bool" type. Someone seems actually to have changed a type from "unsigned" to "bool", and also added an "!= 0" test. And that probably makes the code easier to understand for more people. So that's good. But I will just change the "C" to "pseudo C". gnirre (talk) 21:45, 30 April 2011 (UTC)
Code example and line capacitance
I feel the READ macros should be detailed, otherwise readers may not understand that the pull-ups may require up to 320ns to act if there is a lot of capacitance on the SDA or SCL lines. I suggest:
bool READSCL(void) /* Set SCL as input and return current level of line, 0 or 1 */
{
Set_SCL_As_Input();
Wait( 500ns );
return Get_SCL_Input();
}
And likewise for READSDA(). Hoptroff (talk) 15:57, 20 July 2011 (UTC)
Hot-swapping
"Peripherals can also be added to or removed from the I²C bus while the system is running, which makes it ideal for applications that require hot swapping of components.[citation needed]"
This is implied by the fact that it is based on open-collector logic and the fact that you can't communicate with more than one device at a time... Why do so many "citations needed" come from people who seemingly didn't read the articles?!71.196.246.113 (talk) 10:10, 5 August 2011 (UTC)