Shop OBEX P1 Docs P2 Docs Learn Events
HMC5883L i2c not working with PIC16F886 — Parallax Forums

HMC5883L i2c not working with PIC16F886

fffdddooofffdddooo Posts: 2
edited 2013-11-21 06:56 in General Discussion
Hi!

I'm trying to use HMC5883L module with PIC16F886, Vdd=5V. I've written a simple programa to send data to the module. But it doen't work.

If I use the PIC without the module and I put two 10K pullup resistors at SDA and SCL lines, the program sends data to the i2c bus, but if a plug in the module and remove the 10K pull-up (the module has a 2k2 pull up at SCL and a 4K7 pullup at SDA) then both SCL and SDA remain high, and the PIC is not able to send the START.

If tried to plug the module to the pic with bot 10K pull-up resistors buth then when I turn on the i2c module on the PIC, SCL goes down and it remains down, so the PIC is not able to send the start either.

So i guess is problem with pull-up values, but i don't know what is the problem. Any help please?


regards

Comments

  • BeanBean Posts: 8,129
    edited 2013-11-21 05:14
    The pull-up values are not that critical. Anything from 2.2K to 10K should work fine.

    I'm confused because you say in one case the SDA and SCL stay high, but in the second case SCL stays low. What is the difference in your setup between these two cases ?
    It sounds like you are saying WITH the 10K pullup SCL goes low and stays low, and WITHOUT the 10K pullup both lines say high. That makes no sense...

    It also could be that there is something wrong with the module.

    Bean

    P.S. You do have a common ground connection ???
  • fffdddooofffdddooo Posts: 2
    edited 2013-11-21 06:56
    I know it dos not make sense, but it is what is happening. If I put 10K res on SDA and SCL without the compass module i2c buss work: the pic can send a START condition and data (altough nobody is listening)
    If I connect the pic to the module without pull-up resistors (which is what is supposed to be the correct way because the module have built-in pullups) both libes remanin high and the pic is not able to send a START.
    And with the module and two 10K pull-up SCL goes low in the same moment I enable the pic i2c module (when SCL is configured as open drain) and SDA remains high.
    Connecting 10K resistors as I'm doing put them in parallel with the built in resistors so I have

    SDA 10K || 4k7 = 3K2
    SCL 2K2 || 10K = 1K8

    I'm going to try different resistor values for SCL pull-up but I found it annoying.

    regards
Sign In or Register to comment.