I want to develop my C code for HMC5883L.
ButI have 2 questions for my current code development.
My first question is: But what I found in the datasheet is that the values are in the 2's compliment, so I don't know how to deal with them?! Do I have to take the values as they are in the data registers and convert them to decimal values and that's it? Or I have to convert them from 2's compliment to the original hex values?
This is a quote from the datasheet:
Send 0x3D 0x06 (Read all 6 bytes. If gain is changed then this data set is using previous gain) Convert three 16-bit 2’s compliment hex values to decimal values and assign to X, Z, Y, respectively.
My second question: How o read the data registers? What is the procedure? I saw in the datasheet the following method but I didn't understand it.
Loop Send 0x3D 0x06 (Read all 6 bytes. If gain is changed then this data set is using previous gain) Convert three 16-bit 2’s compliment hex values to decimal values and assign to X, Z, Y, respectively. Send 0x3C 0x03 (point to first data register 03) Wait about 67 ms (if 15 Hz rate) or monitor status register or DRDY hardware interrupt pin End_loop
So, I didn't understand that I send read command then I send write command, so how HMC5883L would return the value to me?
Regards,