3
\$\begingroup\$

I'm working with a PIC18F46J53 and it was working quite well without any troubles. Suddenly, I found a hindrance on my path.

I used RB4 and RB5 pins as I2C bus pins for communicating with an EEPROM (24LC256). And I pulled up the bus lines using external 10k on both SDA and SCL.

Whenever I initialize TRISB pins RB4 and RB5 as inputs a solid 3.2v will appear across them as I2C bus. But recently a problem popped up on my board: one pin, SCL, shows ~3.2V whereas SDA shows 0.8V - I2C,then, didn't work anymore. I cross checked the I/O pin configuration and when I enabled the internal pull-ups on the PORTB the voltage on SDA rose up to 2.0v and I2C worked fine with EEPROM.

From the datasheet:

RBPU: PORTB Pull-up Enable bit

1 = All PORTB pull-ups are disabled
0 = PORTB pull-ups are enabled by individual port latch values

To fix the problem I trust both pins SDA and SCL must have 2.8-3.2 V on the bus when configured as input. But it seems to be working with 2.0V on the SDA pin and 2.9V on SCL.

I would like your inputs to this problem if you have countered any difficulties like this before.

Where should I search to fix the problem? It's working for now but I trust I would have missed something in any case. When and how should one use pull-ups? I have used both external and internal in this case to get I2C working. What is the best way to do so?

\$\endgroup\$

2 Answers 2

5
\$\begingroup\$

Don't use internal pull-ups for I2C. Use external resistors.
In other words, it's a design error when you attempt to use internal pull-ups for I2C (pretty much on any microcontroller).

The datasheet says that internal pull-up current is 50μA min and 400μA max. First, look at the huge variability of the pull-up current. Second, even 400μA is too weak for I2C. Even a 2.5kΩ resistor with Vcc=3.3V would generate a 1.3mA pull-up current.

Related threads:
What happens if I omit the pullup resistors on I2C lines? The O.P. was using internal pull-ups without knowing it. Illuminating oscilloscope plots in that thread.
Is there a correct resistance value for I2C pull-up resistors?

\$\endgroup\$
3
  • \$\begingroup\$ Thank you.I have understood what you said nick.I never used internal pull up before but now the sda pin shows only .8v when internal pullup is disabled,But SCL pins shows 3.2 v.IS'nt that anomalous behaviour?.I have indeed used pullup resistors on my board nick \$\endgroup\$
    – Rookie91
    Commented Sep 12, 2014 at 4:30
  • \$\begingroup\$ @Rookie91 If you've used pullups on your board, the internal pullups should not be enabled \$\endgroup\$ Commented Sep 12, 2014 at 13:11
  • \$\begingroup\$ @ScottSeidman Thank you very much scott for your time.I will cross check and get back to you \$\endgroup\$
    – Rookie91
    Commented Sep 12, 2014 at 13:24
3
\$\begingroup\$

I'm not sure I'm parsing your question correctly, but if it worked with internal pull-ops but not when pull-ups were disabled, and you have external 1K resistors, I would have to think there could be only two explanations:

  1. The SDA pull-up is broken - badly soldered, cracked, open trace, etc.

  2. Your configuration changes unexpectedly affected something else.

If you measure the pull-up current you should be able to distinguish which it is. Suggest you always turn off internal pull-ups to avoid the situation of 'almost working', 'almost not working'

\$\endgroup\$
1
  • \$\begingroup\$ Thank you very much.I will have to cross check about broken thing and will get back to you.But how will the configuration bits affects the pullup?.I will be enlightened if i get info on that :).Again thanks a lot for your time. \$\endgroup\$
    – Rookie91
    Commented Sep 12, 2014 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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