Old post, new member
I have been trying to get one of these working for at least 2 weeks and it is almost out of the window time.
Read and noted all the references that I can find. I am using a PIC, not an Arduino ( I suppose I should admit at this stage that I don't even know what an Arduino is, it may save embarrassment later)
However, back to the HMC5883L. Much tearing of hair and emails later not only is the data sheet wrong in the respects mentioned in this thread it is also wrong in a few other places, some solved, some not. Attached is a comparison PDF between this chip and it's predecessor. Some things mentioned in that not mentioned anywhere and also some things in that which are just incomprehensible and some things that are wrong.
According to that PDF there is no roll back on the programme counter, sadly this is incorrect, there is a roll back but if you read 6 bytes only then you will never get another set of readings, status locks the update as the chip believes you have not read the 6 registers. Best understanding I can get of the internals of this chip is that if I read from 10 to 8 or 9 to 8 (roll back from 12 to 0) then I will get a continually changing set of results from the registers 3 to 8. If I read form 11 to 8 the registers stay locked.
This I can cope with though it does mean I cannot run the chip as fast as I would like because of the I2C times.
My main problem is that if Y and Z are negative all is good, if I rotate such that either Y or Z go positive (that is as far as I can tell) then the I2C internals of the chip crash and I have to power cycle the chip to get it working again.
My I2C routines are years old and have been used for lots of devices before, even so I completely rewrote them and the chip behaves the same way. I cannot think that my routines have problems because no matter what sort of cock up I have made in the routines if I send a series of I2CStop then any I2C device that is correct will wake up again, that is written in the I2C spec.
I have to add that as far as I am concerned this chip and associated datasheet are the worst example I have ever seen in my life. Who would think that getting a chip working, with all the available information, would involve what can only be described as "Hacking" with so much suck it and see involved.
Anyway, any suggestions as to what is doing this? Checked the waveforms as described in here for the capacitors, all is good. I have bit analysed the streams with the scope (at least 5 years wear and tear on the eyes doing that) and can find no NOT-ACK examples, have incorporated clock stretching and as far as I can work out everything that the I2C should have ( I am using assembler here not a high level language).
Truly stuck and about to go searching for an alternative, sadly there don't seem to be any that I can find. Anyone any suggestions on that front?
I'll stop waffling now and wait to see if anyone can be bothered to read this drivel.