3
\$\begingroup\$

I have three i2c devices connected to AVR microcontroller. On the i2c bus on master side there are two pull ups with 2k7 ohm. What im experiencing is that when i power up the microcontroller devices cannot "drop the line"/initialize. After reseting the uC, everything is ok. On the startup routine of uC there are some initializations that takes around 100ms. Could this be because of pull-up values or should i wait for more time for initialization ?

UPDATE: Internal pull-up is disabled. Using pull-up for each line.

\$\endgroup\$
  • \$\begingroup\$ Two pullups? Are they pulling up to the same voltage as the uC power? \$\endgroup\$ – pjc50 Oct 10 '12 at 8:34
  • \$\begingroup\$ @pjc50 - I assume he means one for each of the data and clock lines. \$\endgroup\$ – Trygve Laugstøl Oct 10 '12 at 9:06
  • \$\begingroup\$ Yes, one for each line. Sorry i was not clear enough. \$\endgroup\$ – Gossamer Oct 10 '12 at 9:26
3
\$\begingroup\$

I don't think there's anything wrong with the pull-up value. I2C drivers mus be able to sink at least 3 mA, and the minimum of 2 kΩ is determined with that in mind: 3 mA through 2 kΩ is enough to pull a 5 V bus voltage all the way to ground.

It looks to me that the I/Os haven't been properly initialized after power-on. Are you sure the reset did its work properly? Does the AVR have an internal reset (you don't mention which type you're using, and I'm not going to read dozens of datasheets), or do you have an RC circuit on an external reset pin, or maybe a reset controller like the MAX809?

I would suggest to add some code which indicates proper reset, like for instance a LED blinking at 2 Hz. Do the initialization for the blinking immediately after the initialization of the I2C. If the LED blinks the port will be properly initialized, most likely not if the LED doesn't blink.

Further reading
I2C-bus specification and user manual
Using the TWI module as I2C master, Atmel Application Note AVR315
Using the TWI module as I2C slave, Atmel Application Note AVR311 (for completeness :-))

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ But for the TWi there is no initialization except setting the TWBR value for the clock speed. Im using external reset pin. \$\endgroup\$ – Gossamer Oct 10 '12 at 9:33
  • \$\begingroup\$ In the arduino twi.c (code.google.com/p/arduino/source/browse/trunk/libraries/Wire/…) the I2C pins have their internal pull-ups activated. Have you done this? \$\endgroup\$ – geometrikal Oct 10 '12 at 9:38
  • 1
    \$\begingroup\$ @Gossamer - The TWi won't generate a start condition if it sees the bus as free. It will see a low level if the voltage is less than 0.3 Vcc. Is it possible that the bus voltage comes up slower than the AVR's? Do you have a scope available to look at both after power-up? \$\endgroup\$ – stevenvh Oct 10 '12 at 9:46
  • \$\begingroup\$ That could be the case, i will try to record the power-up transition... \$\endgroup\$ – Gossamer Oct 10 '12 at 9:58
  • \$\begingroup\$ It was "fast" power-up issue after all. Ive increased the delay in a initialization routine and devices worked right away. There are 3 voltage converters on the same board. AVR and i2c devices are on different ones.. \$\endgroup\$ – Gossamer Oct 11 '12 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.