this forum has helped me a lot of times without having to post something so this is actually my first post.
My problem: I have an arduino due and I am trying to communicate with HMC5883l through I2C. I have already connected the HMC to my arduino uno and it worked fine so I believe the sensor is ok. When I connected it to arduino due though the values don't change when I rotate the board HMC is mounted on. The HMC is connected to SDA(20) and SCL(21) without any pull-up resistors and I power it with 3.3V.
Like I said the code works for arduino uno so I don't think there is a problem there. I changed it anyway and the receiving values changed but still remained steady during rotation.
If you have a long I2C bus, you have ringing on the falling edges.
It appears that the AVRs have 50ns glitch filters and falling edge slew limiters built into the TWI hardware. The ARM Cortex M3 has nothing to filter glitchs.
I had the same issue using the HMC5983 magnetometer, (it's the same as the HMC5883L, but with temperature compensation), in conjuction with an Atmel SAMD51 ARM Cortex M4F micro-controller. The falling edges on SAMD51 are particularly harsh. Undershoot and ringing on both the clock and data signals caused the magnetometer to crash with the SCL line held low, effectively hanging the I2C bus.
The same set-up had worked faultlessly with the SAMD21 ARM Cortex M0+ micro-controller, (used on the Arduino Zero).
Rather than adding extra capacitance, (the I2C has a maximum bus capacitance of 400pF), I instead added two 100 Ohm series resistors to the SCL and SDA lines, (in addition to the standard I2C pull-ups at 2.2kOhms). These current limiting resistors reduced the signal slew rate, undershoot and ringing, allowing the I2C bus to operate normally (at 400kHz) oncemore.