English
Language : 

HMC5983-DEM Datasheet, PDF (26/28 Pages) Honeywell Accelerometers – 3-Axis Digital Compass IC
HMC5983
I²C OPERATIONAL EXAMPLES
The HMC5983 has a fairly quick stabilization time from no voltage to stable and ready for data retrieval. The nominal 56
milli-seconds with the factory default single measurement mode means that the six bytes of magnetic data registers
(DXRA, DXRB, DZRA, DZRB, DYRA, and DYRB) are filled with a valid first measurement.
To change the measurement mode to continuous measurement mode, after the power-up time send the three bytes:
0x3C 0x02 0x00
This writes the 00 into the second register or mode register to switch from single to continuous measurement mode
setting. With the data rate at the factory default of 15Hz updates, a 67 milli-second typical delay should be allowed by the
I²C master before querying the HMC5983 data registers for new measurements. To clock out the new data, send:
0x3D, and clock out DXRA, DXRB, DZRA, DZRB, DYRA, and DYRB located in registers 3 through 8. The HMC5983 will
automatically re-point back to register 3 for the next 0x3D query. All six data registers must be read properly before new
data can be placed in any of these data registers.
Below is an example of a (power-on) initialization process for “continuous-measurement mode” via I²C interface:
1. Write CRA (00) – send 0x3C 0x00 0x70 (8-average, 15 Hz default, normal measurement)
2. Write CRB (01) – send 0x3C 0x01 0xA0 (Gain=5, or any other desired gain)
3. Write Mode (02) – send 0x3C 0x02 0x00 (Continuous-measurement mode)
4. Wait 6 ms or monitor status register or DRDY hardware interrupt pin
5. 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
Below is an example of a (power-on) initialization process for “single-measurement mode” via I²C interface:
1. Write CRA (00) – send 0x3C 0x00 0x70 (8-average, 15 Hz default or any other rate, normal measurement)
2. Write CRB (01) – send 0x3C 0x01 0xA0 (Gain=5, or any other desired gain)
3. For each measurement query:
Write Mode (02) – send 0x3C 0x02 0x01 (Single-measurement mode)
Wait 6 ms or monitor status register or DRDY hardware interrupt pin
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.
SPI OPERATIONAL EXAMPLES
To read Configuration B register
Lower CS line
Write 0x81 to the SPI bus
Read 1 byte from SPI bus
Raise CS line
To read Status
Lower CS line
Write 0x89 to the SPI bus
Read 1 byte from SPI bus
Raise CS line
To write Configuration B register
Lower CS line
Write 0x01 to the SPI bus
Write 0xVV to the SPI bus (VV is the value to
be written to register B)
Raise CS line
To read output
Lower CS line
Write 0xC3 to the SPI bus
Read 6 byte from SPI bus
Raise CS line
26
www.honeywell.com