Shop OBEX P1 Docs P2 Docs Learn Events
I2C pin choices — Parallax Forums

I2C pin choices

sylvie369sylvie369 Posts: 1,622
edited 2008-11-18 17:46 in Propeller 1
I'm trying to use an LIS302DL accelerometer with an I2C interface on a Propeller Protoboard. I set it up with SCL and SDA as pins 0 and 1, but I get no response from the device. To see where the problem was, I took it off and set it up on a Propstick, using pins 28 and 29 there: that worked fine. Then I moved the wires over to pins 0 and 1 (and changed the code), and again, no response. I did dig through the various objects called by the program (lis302dlobject and Basic_i2c_Driver) to see if pin 28 was hard-coded anywhere: that didn't seem to be the problem. I did some other trouble-shooting, such as calling readlocation in the Basic_i2c_Driver directly from my own program: same results. It works if I use pins 28 and 29, and does not work if I use pins 0 and 1. This matters, by the way, because pins 28 and 29 are not available on the Protoboard.

So just now I remembered that on the BS2pe Mobo there are only a couple of different pin options for i2c, and I thought maybe that's the case for the Propeller as well. I moved it over to pins 8 and 9 on the Propstick, and sure enough, it worked. That should work for me on the Protoboard (those pins are available and in a good position), but I'm a bit mystified about why. I'd thought that you could use any consecutive pair of pins for i2c. Are only certain pins available for SCL and SDA i2c connections?

Comments

  • RaymanRayman Posts: 14,364
    edited 2008-11-18 13:36
    Sounds like a pull-up problem to me... You're supposed to have pull-up resistors on SCL and SDA. Parallax puts always puts one on Pin29 (SDA), but leaves it off 28, so maybe you don't need one on SCL.
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-11-18 13:50
    Ah, I hadn't thought of that. I'll take a look. Basically just run the appropriate resistors from the pins I'm using to one of the +3.3V rails, right?

    Thanks.
  • RaymanRayman Posts: 14,364
    edited 2008-11-18 15:56
    Yes, that's it... I think 10k is a good value.
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-11-18 17:46
    Yup, a pair of 10K pullup resistors did the trick. Thanks.
Sign In or Register to comment.