This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Communication Problem - I2C protocol - Magnetic field sensor - HMC5883L

Other Parts Discussed in Thread: CONTROLSUITE

Good morning,

I'm software developer and I'm try to do a communication between the launchpad C2000 and a magnetic sensor (HMC5883L) to control the BLDC motor speed. Then I have tried some ways and I would like that someone can help me and to explain what I did wrong.

This sensor has a example code in Arduino that is easy to see the bytes protocol. I have tested and confirmed the code.

This site show the example code: https://www.sparkfun.com/tutorials/301

Then, I found a I2C communication example within controlSUITE reading a eeprom memory, then I have edited for my case. But it seems like a good signal. the clock means like strange and when plug the sensor the wave just vanish. I don't know exactly why it happens. I'm using 28 and 29 pin.

I thought that the clock and data have a pull-up resistor, but when I put it, the communications stop. look the wave in the pic.

Then I try another way, using a basic I2C code that I found on this forum. But it didn't work...

I would like to know if someone can help me, I have to real some values from this sensor.

The communication is basically:

  startI2C(address); //open communication with HMC5883
  send(0x02); //select mode register
  send(0x00); //continuous measurement mode
  read(6xBytes);// three fields, two Bytes each


I hope that somebody can help
Thanks for all.
  • Yuri,

    It looks like your pull-up resistor is too weak to work at your SCL frequency (~250 kHz). The I2C spec lists the max rise time as 300 nanoseconds, but yours is ~4 microseconds. The range of resistor values you can use depends on the bus capacitance, but 1000 ohms is a good place to start.

    If you want to learn more about calculating the allowed resistor values, there's a discussion of I2C pull-ups on Stack Exchange:

    http://electronics.stackexchange.com/questions/1849/is-there-a-correct-resistance-value-for-pull-up-resistors

    Or you can go straight to the source and consult section 7.1 of the I2C bus spec:

    http://www.nxp.com/documents/user_manual/UM10204.pdf