MAG3110 – Bare metal example project

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MAG3110 – Bare metal example project

MAG3110 – Bare metal example project

Hello community,

This time, I would like to share a simple bare metal example code using the MAG3110 , the digital Magnetometer from NXP.

I created this example code with the FRDM-KL25Z  platform and the FRDM-FXS-MULT2-B sensor expansion board. The complete source code is written in the Kinetis Design Studio V3.2.0  in collaboration with the FreeMASTER  tool in order to visualize the magnetic data.

This document guides you through the initialization process and how to appreciate the demonstration.

MAG3110.jpg

Section 1: Initialization of the MKL25Z128 MCU.

Section 2: Initialization of the MAG3110.

Section 3: Simple magnetic hard-iron offset calibration.

Section 4: Output data reading using an interrupt technique.

Section 5: Conversion of the output values.

Section 6: FreeMASTER tool.

1. Initialization of the MKL25Z128 MCU

Based on the figure below, the SCL and SDA signals, from the I2C Module, are connected to the PTC1 and PTC2 pins respectively. The INT1 output of the MAG3110 is connected to the PTD4 pin of the KL25Z.

FRDM-FXS-MULT2-B.jpg

Please make sure the 2&3 pins of the J3 are connected together using a jumper at the FRDM-FXS-MULT2-B.

J3.jpg

The RGB LED from the FRDM-KL25Z is also set using the PTB18 and PTB19 pins as GPIOs.

//I2C1 module initialization
SIM_SCGC4 |= SIM_SCGC4_I2C1_MASK;         // Turn on clock to I2C0 module
SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;        // Turn on clock to Port C module
PORTC_PCR1 = PORT_PCR_MUX(2);             // PTC1 pin is I2C0 SCL line
PORTC_PCR2 = PORT_PCR_MUX(2);             // PTC2 pin is I2C0 SDA line
I2C1_F  = 0x14;                           // SDA hold time = 2.125us, SCL start hold time = 4.25us, SCL stop hold time = 5.125us
I2C1_C1 = I2C_C1_IICEN_MASK;              // Enable I2C0 module


//Configure the PTD4 pin (connected to the INT1 of the MAG3110) for rising edge interrupts
SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;        // Turn on clock to Port D module
PORTD_PCR4  |= (0|PORT_PCR_ISF_MASK|      // Clear the interrupt flag
                  PORT_PCR_MUX(0x1)|      // PTD4 is configured as GPIO
                  PORT_PCR_IRQC(0x09));   // PTD4 is configured for rising edge interrupts (MAG3110 generates low to high signal)

//Configure RGB LED
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;        // Turn on clock to Port B module

PORTB_PCR19 = PORT_PCR_MUX(1);            // PTB19 is configured as GPIO
GPIOB_PDDR |= (1 << 19);                  // Configure pin as output
GPIOB_PSOR |= (1 << 19);                  // Turn OFF GREEN LED

PORTB_PCR18 = PORT_PCR_MUX(1);            // PTB18 is configured as GPIO
GPIOB_PDDR |= (1 << 18);                  // Configure pin as output
GPIOB_PCOR |= (1 << 18);                  // Turn ON RED LED


//Enable PORTD interrupt on NVIC
NVIC_EnableIRQ(PORTD_IRQn);               // Enable interrupts
NVIC_ClearPendingIRQ(PORTD_IRQn);         // Clear pending interrupts
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

2. Initialization of the MAG3110

The MAG3110 is capable of measuring magnetic fields with an output data rate (ODR) up to 80 Hz. In this case, the ODR of the MAG3110 is set at 20Hz.

The automatic resets are enabled. When new measurement data is available, the INT1 pin triggers a software interrupt.

The WHO_AM_I register is read in order to verify the correct communication with the magnetometer.

I2C_WriteRegister(MAG3110_I2C_ADDRESS, CTRL_REG2, 0x80);  // Enable automatic resets

WhoAmI = I2C_ReadRegister(MAG3110_I2C_ADDRESS, WHO_AM_I); // Read WHO_AM_I Register

I2C_WriteRegister(MAG3110_I2C_ADDRESS, CTRL_REG1, 0x11);  // ODR 20Hz (0.05s), Active mode


‍‍‍‍‍‍‍

3. Simple magnetic hard-iron offset calibration.

Please note that the magnetometer readings must be corrected for Hard-Iron and Soft-Iron effects. If you are interested in more complex algorithms you may refer to the NXP E-Compass Software.

As an alternative, a method to calibrate the hard iron offset is rotating the MAG3110 in a figure of eight twisting motions for a few seconds, record the minimum and maximum magnetometer readings, compute the corresponding offset values by using the min/max averaging and then either subtract these offset values from the current magnetometer measurements or write them in the user offset registers with CTRL_REG2[RAW] = 0.

eight.jpg

The hard iron offset calibration is done as follow:

short Xout_16_bit_avg, Yout_16_bit_avg, Zout_16_bit_avg;
short Xout_16_bit_max, Yout_16_bit_max, Zout_16_bit_max;
short Xout_16_bit_min, Yout_16_bit_min, Zout_16_bit_min;
short i=0;

while (i < 200) // Calibration process ~10s (200 samples * 1/20Hz)
{
    if (DataReady)
        {
            DataReady= 0;

            I2C_ReadMultiRegisters(MAG3110_I2C_ADDRESS, OUT_X_MSB, 6, MagData);        // Read data output registers 0x01-0x06

            Xout_16_bit = ((short) (MagData[0]<<8 | MagData[1]));        // Compute 16-bit X-axis output value
            Yout_16_bit = ((short) (MagData[2]<<8 | MagData[3]));        // Compute 16-bit Y-axis output value
            Zout_16_bit = ((short) (MagData[4]<<8 | MagData[5]));        // Compute 16-bit Z-axis output value

            if (i == 0)
            {
                Xout_16_bit_max = Xout_16_bit;
                Xout_16_bit_min = Xout_16_bit;

                Yout_16_bit_max = Yout_16_bit;
                Yout_16_bit_min = Yout_16_bit;

                Zout_16_bit_max = Zout_16_bit;
                Zout_16_bit_min = Zout_16_bit;
            }

            // Check to see if current sample is the maximum or minimum X-axis value
            if (Xout_16_bit > Xout_16_bit_max) {Xout_16_bit_max = Xout_16_bit;}
            if (Xout_16_bit < Xout_16_bit_min) {Xout_16_bit_min = Xout_16_bit;}

            // Check to see if current sample is the maximum or minimum X-axis value
            if (Yout_16_bit > Yout_16_bit_max) {Yout_16_bit_max = Yout_16_bit;}
            if (Yout_16_bit < Yout_16_bit_min) {Yout_16_bit_min = Yout_16_bit;}

            // Check to see if current sample is the maximum or minimum X-axis value
            if (Zout_16_bit > Zout_16_bit_max) {Zout_16_bit_max = Zout_16_bit;}
            if (Zout_16_bit < Zout_16_bit_min) {Zout_16_bit_min = Zout_16_bit;}

            i++;
        }
}


Xout_16_bit_avg = (Xout_16_bit_max + Xout_16_bit_min) / 2;    // X-axis hard-iron offset
Yout_16_bit_avg = (Yout_16_bit_max + Yout_16_bit_min) / 2;    // Y-axis hard-iron offset
Zout_16_bit_avg = (Zout_16_bit_max + Zout_16_bit_min) / 2;    // Z-axis hard-iron offset

// Left-shift by one as magnetometer offset registers are 15-bit only, left justified
Xout_16_bit_avg <<= 1;
Yout_16_bit_avg <<= 1;
Zout_16_bit_avg <<= 1;

I2C_WriteRegister(MAG3110_I2C_ADDRESS, CTRL_REG1, 0x00);  // Standby mode

// Set Offset
I2C_WriteRegister(MAG3110_I2C_ADDRESS, OFF_X_LSB, (char)(Xout_16_bit_avg & 0xFF));
I2C_WriteRegister(MAG3110_I2C_ADDRESS, OFF_X_MSB, (char)((Xout_16_bit_avg >>8) & 0xFF));
I2C_WriteRegister(MAG3110_I2C_ADDRESS, OFF_Y_LSB, (char)(Yout_16_bit_avg & 0xFF));
I2C_WriteRegister(MAG3110_I2C_ADDRESS, OFF_Y_MSB, (char)((Yout_16_bit_avg >>8) & 0xFF));
I2C_WriteRegister(MAG3110_I2C_ADDRESS, OFF_Z_LSB, (char)(Zout_16_bit_avg & 0xFF));
I2C_WriteRegister(MAG3110_I2C_ADDRESS, OFF_Z_MSB, (char)((Zout_16_bit_avg >>8) & 0xFF));

I2C_WriteRegister(MAG3110_I2C_ADDRESS, CTRL_REG1, 0x11);  //  Active mode again
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

4. Output data reading using an interrupt technique.

At the ISR, the interrupt flag is clear and the DataReady variable is set in order to know that a new magnetic measurement is ready.

void PORTD_IRQHandler()
{
    PORTD_PCR4 |= PORT_PCR_ISF_MASK;            // Clear the interrupt flag
    DataReady= 1;
}
‍‍‍‍‍

5. Conversion of the output values

The output values from magnetometer are converted to signed 16-bit integer values and afterwards to real values in microtesla (µT).

for(;;){ 
   
 if (DataReady)    
 {        
    DataReady= 0;     
   
    I2C_ReadMultiRegisters(MAG3110_I2C_ADDRESS, OUT_X_MSB, 6, MagData);        // Read data output registers 0x01-0x06        

    // 16-bit magnetometer data        
    Xout_16_bit = ((short) (MagData[0]<<8 | MagData[1]));        // Compute 16-bit X-axis output value        
    Yout_16_bit = ((short) (MagData[2]<<8 | MagData[3]));        // Compute 16-bit Y-axis output value        
    Zout_16_bit = ((short) (MagData[4]<<8 | MagData[5]));        // Compute 16-bit Z-axis output value        

    // Magnetometer data converted to microteslas       
    Xout_uT = (float)Xout_16_bit / SENSITIVITY;     // Compute X-axis output magnetic value in uT        
    Yout_uT = (float)Yout_16_bit / SENSITIVITY;     // Compute Y-axis output magnetic value in uT       
    Zout_uT = (float)Zout_16_bit / SENSITIVITY;     // Compute Z-axis output magnetic value in uT    
 }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

6. FreeMASTER

FreeMASTER is a user-friendly real-time debug monitor and data visualization tool that you can use for any application development and information management. In this case, it is used in order to visualize the magnetic data.

FreeMaster.jpg

In case you have problems with the communication port, please go to Project / Options…

Select Plug-in Module and choose the FreeMASTER BDM Communication Plug-in option.

options.jpg

Select configure and make sure the P&E Kinetis is selected.

Select OK and Start the communication.

Please find attached the complete source code, including the FreeMASTER project.

You are invited to take part of the NXP community where you can post all your questions and you may find useful material for your projects.

I hope you find useful and funny this sample project. Any suggestion will be appreciated. Smiley Happy

Best Regards,

David

Labels (1)
Attachments
%3CLINGO-SUB%20id%3D%22lingo-sub-1100619%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMAG3110%20%E2%80%93%20Bare%20metal%20example%20project%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1100619%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20community%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThis%20time%2C%20I%20would%20like%20to%20share%20a%20simple%20bare%20metal%20example%20code%20using%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Fmagnetometers%2Fsample-data-sets-for-inertial-and-magnetic-sensors%2Fhigh-accuracy-3d-magnetometer%3AMAG3110%3Ffsrch%3D1%26amp%3Bsr%3D1%26amp%3BpageNum%3D1%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20title%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Fmagnetometers%2Fsample-data-sets-for-inertial-and-magnetic-sensors%2Fhigh-accuracy-3d-magnetometer%3AMAG3110%3Ffsrch%3D1%26amp%3Bsr%3D1%26amp%3BpageNum%3D1%22%20target%3D%22_blank%22%3EMAG3110%3C%2FA%3E%20%2C%20the%20digital%20%3CSTRONG%3EMagnetometer%20%3C%2FSTRONG%3Efrom%20NXP.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20created%20this%20example%20code%20with%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsoftware-and-tools%2Fhardware-development-tools%2Ffreedom-development-boards%2Ffreedom-development-platform-for-kinetis-kl14-kl15-kl24-kl25-mcus%3AFRDM-KL25Z%3Flang_cd%3Den%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20title%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsoftware-and-tools%2Fhardware-development-tools%2Ffreedom-development-boards%2Ffreedom-development-platform-for-kinetis-kl14-kl15-kl24-kl25-mcus%3AFRDM-KL25Z%3Flang_cd%3Den%22%20target%3D%22_blank%22%3EFRDM-KL25Z%3C%2FA%3E%26nbsp%3B%20platform%20and%20the%20%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsoftware-and-tools%2Fhardware-development-tools%2Ffreedom-development-boards%2Ffrdm-fxs-mult2-b-freedom-development-platform-for-freescale-sensors-with-bluetooth.%3AFRDM-FXS-MULT2-B%3Flang_cd%3Den%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20title%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsoftware-and-tools%2Fhardware-development-tools%2Ffreedom-development-boards%2Ffrdm-fxs-mult2-b-freedom-development-platform-for-freescale-sensors-with-bluetooth.%3AFRDM-FXS-MULT2-B%3Flang_cd%3Den%22%20target%3D%22_blank%22%3EFRDM-FXS-MULT2-B%3C%2FA%3E%20%3C%2FSPAN%3Esensor%20expansion%20board.%20The%20complete%20source%20code%20is%20written%20in%20the%20%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsoftware-and-tools%2Frun-time-software%2Fkinetis-software-and-tools%2Fides-for-kinetis-mcus%2Fkinetis-design-studio-integrated-development-environment-ide%3AKDS_IDE%3Ffsrch%3D1%26amp%3Bsr%3D1%26amp%3BpageNum%3D1%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20title%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsoftware-and-tools%2Frun-time-software%2Fkinetis-software-and-tools%2Fides-for-kinetis-mcus%2Fkinetis-design-studio-integrated-development-environment-ide%3AKDS_IDE%3Ffsrch%3D1%26amp%3Bsr%3D1%26amp%3BpageNum%3D1%22%20target%3D%22_blank%22%3EKinetis%20Design%20Studio%20V3.2.0%3C%2FA%3E%26nbsp%3B%20%3C%2FSPAN%3Ein%20collaboration%20with%20the%3CSPAN%20style%3D%22color%3A%20red%3B%22%3E%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fpower-management%2Fwireless-charging-ics%2Ffreemaster-run-time-debugging-tool%3AFREEMASTER%3Ffsrch%3D1%26amp%3Bsr%3D1%26amp%3BpageNum%3D1%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20title%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fpower-management%2Fwireless-charging-ics%2Ffreemaster-run-time-debugging-tool%3AFREEMASTER%3Ffsrch%3D1%26amp%3Bsr%3D1%26amp%3BpageNum%3D1%22%20target%3D%22_blank%22%3EFreeMASTER%3C%2FA%3E%26nbsp%3B%20%3C%2FSPAN%3Etool%20in%20order%20to%20visualize%20the%20magnetic%20data.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThis%20document%20guides%20you%20through%20the%20initialization%20process%20and%20how%20to%20appreciate%20the%20demonstration.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MAG3110.jpg%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MAG3110.jpg%22%20style%3D%22width%3A%20243px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111519i4CB2182324828767%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22MAG3110.jpg%22%20alt%3D%22MAG3110.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESection%201%3A%20Initialization%20of%20the%20MKL25Z128%20MCU.%3C%2FP%3E%3CP%3ESection%202%3A%20Initialization%20of%20the%20%3CSTRONG%3EMAG3110%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3ESection%203%3A%20Simple%20magnetic%20hard-iron%20offset%20calibration.%3C%2FP%3E%3CP%3ESection%204%3A%20Output%20data%20reading%20using%20an%20interrupt%20technique.%3C%2FP%3E%3CP%3ESection%205%3A%20Conversion%20of%20the%20output%20values.%3C%2FP%3E%3CP%3ESection%206%3A%20FreeMASTER%20tool.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CH2%20id%3D%22toc-hId--1416460578%22%20id%3D%22toc-hId--1416460578%22%20id%3D%22toc-hId--499134005%22%3E1.%20Initialization%20of%20the%20MKL25Z128%20MCU%3C%2FH2%3E%3CP%3E%3C%2FP%3E%3CP%3EBased%20on%20the%20figure%20below%2C%20the%20SCL%20and%20SDA%20signals%2C%20from%20the%20I2C%20Module%2C%20are%20connected%20to%20the%20%3CEM%3EPTC1%3C%2FEM%3E%20and%20%3CEM%3EPTC2%3C%2FEM%3E%20pins%20respectively.%20The%20INT1%20output%20of%20the%20MAG3110%20is%20connected%20to%20the%20%3CEM%3EPTD4%3C%2FEM%3E%20pin%20of%20the%20KL25Z.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22FRDM-FXS-MULT2-B.jpg%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22FRDM-FXS-MULT2-B.jpg%22%20style%3D%22width%3A%20629px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111520iCD5A940682042783%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22FRDM-FXS-MULT2-B.jpg%22%20alt%3D%22FRDM-FXS-MULT2-B.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EPlease%20make%20sure%20the%202%26amp%3B3%20pins%20of%20the%20J3%20are%20connected%20together%20using%20a%20jumper%20at%20the%20FRDM-FXS-MULT2-B.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22J3.jpg%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22J3.jpg%22%20style%3D%22width%3A%20549px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111521i2CAA4085FCA1F0FA%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22J3.jpg%22%20alt%3D%22J3.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20RGB%20LED%20from%20the%20FRDM-KL25Z%20is%20also%20set%20using%20the%20%3CEM%3EPTB18%3C%2FEM%3E%20and%20%3CEM%3EPTB19%3C%2FEM%3E%20pins%20as%20GPIOs.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CPRE%20class%3D%22language-cpp%20line-numbers%22%3E%3CCODE%3E%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2FI2C1%20module%20initialization%3C%2FSPAN%3E%0ASIM_SCGC4%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20SIM_SCGC4_I2C1_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Turn%20on%20clock%20to%20I2C0%20module%3C%2FSPAN%3E%0ASIM_SCGC5%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20SIM_SCGC5_PORTC_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Turn%20on%20clock%20to%20Port%20C%20module%3C%2FSPAN%3E%0APORTC_PCR1%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22token%20function%22%3EPORT_PCR_MUX%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E2%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20PTC1%20pin%20is%20I2C0%20SCL%20line%3C%2FSPAN%3E%0APORTC_PCR2%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22token%20function%22%3EPORT_PCR_MUX%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E2%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20PTC2%20pin%20is%20I2C0%20SDA%20line%3C%2FSPAN%3E%0AI2C1_F%26nbsp%3B%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x14%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20SDA%20hold%20time%20%3D%202.125us%2C%20SCL%20start%20hold%20time%20%3D%204.25us%2C%20SCL%20stop%20hold%20time%20%3D%205.125us%3C%2FSPAN%3E%0AI2C1_C1%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20I2C_C1_IICEN_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Enable%20I2C0%20module%3C%2FSPAN%3E%0A%0A%0A%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2FConfigure%20the%20PTD4%20pin%20(connected%20to%20the%20INT1%20of%20the%20MAG3110)%20for%20rising%20edge%20interrupts%3C%2FSPAN%3E%0ASIM_SCGC5%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20SIM_SCGC5_PORTD_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Turn%20on%20clock%20to%20Port%20D%20module%3C%2FSPAN%3E%0APORTD_PCR4%26nbsp%3B%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E0%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3EPORT_PCR_ISF_MASK%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Clear%20the%20interrupt%20flag%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22token%20function%22%3EPORT_PCR_MUX%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E0x1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20PTD4%20is%20configured%20as%20GPIO%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22token%20function%22%3EPORT_PCR_IRQC%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E0x09%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20PTD4%20is%20configured%20for%20rising%20edge%20interrupts%20(MAG3110%20generates%20low%20to%20high%20signal)%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2FConfigure%20RGB%20LED%3C%2FSPAN%3E%0ASIM_SCGC5%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20SIM_SCGC5_PORTB_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Turn%20on%20clock%20to%20Port%20B%20module%3C%2FSPAN%3E%0A%0APORTB_PCR19%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22token%20function%22%3EPORT_PCR_MUX%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20PTB19%20is%20configured%20as%20GPIO%3C%2FSPAN%3E%0AGPIOB_PDDR%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%26lt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E19%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Configure%20pin%20as%20output%3C%2FSPAN%3E%0AGPIOB_PSOR%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%26lt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E19%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Turn%20OFF%20GREEN%20LED%3C%2FSPAN%3E%0A%0APORTB_PCR18%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22token%20function%22%3EPORT_PCR_MUX%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20PTB18%20is%20configured%20as%20GPIO%3C%2FSPAN%3E%0AGPIOB_PDDR%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%26lt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E18%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Configure%20pin%20as%20output%3C%2FSPAN%3E%0AGPIOB_PCOR%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%26lt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E18%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Turn%20ON%20RED%20LED%3C%2FSPAN%3E%0A%0A%0A%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2FEnable%20PORTD%20interrupt%20on%20NVIC%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3ENVIC_EnableIRQ%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EPORTD_IRQn%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Enable%20interrupts%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3ENVIC_ClearPendingIRQ%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EPORTD_IRQn%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Clear%20pending%20interrupts%3C%2FSPAN%3E%0A%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%3CSPAN%20class%3D%22line-numbers-rows%22%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CH2%20id%3D%22toc-hId-1071052255%22%20id%3D%22toc-hId-1071052255%22%20id%3D%22toc-hId-1988378828%22%3E2.%20Initialization%20of%20the%20MAG3110%3C%2FH2%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20MAG3110%20is%20capable%20of%20measuring%20magnetic%20fields%20with%20an%20output%20data%20rate%20(ODR)%20up%20to%2080%20Hz.%20In%20this%20case%2C%20the%20ODR%20of%20the%20MAG3110%20is%20set%20at%2020Hz.%3C%2FP%3E%3CP%3EThe%20automatic%20resets%20are%20enabled.%20When%20new%20measurement%20data%20is%20available%2C%20the%20INT1%20pin%20triggers%20a%20software%20interrupt.%3C%2FP%3E%3CP%3EThe%20WHO_AM_I%20register%20is%20read%20in%20order%20to%20verify%20the%20correct%20communication%20with%20the%20magnetometer.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CPRE%20class%3D%22line-numbers%20language-csharp%22%3E%3CCODE%3E%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20CTRL_REG2%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x80%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Enable%20automatic%20resets%3C%2FSPAN%3E%0A%0AWhoAmI%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22token%20function%22%3EI2C_ReadRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20WHO_AM_I%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Read%20WHO_AM_I%20Register%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20CTRL_REG1%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x11%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20ODR%2020Hz%20(0.05s)%2C%20Active%20mode%3C%2FSPAN%3E%0A%0A%0A%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%3CSPAN%20class%3D%22line-numbers-rows%22%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CH2%20id%3D%22toc-hId--736402208%22%20id%3D%22toc-hId--736402208%22%20id%3D%22toc-hId-180924365%22%3E3.%20Simple%20magnetic%20hard-iron%20offset%20calibration.%3C%2FH2%3E%3CP%3E%3C%2FP%3E%3CP%3EPlease%20note%20that%20the%20magnetometer%20readings%20must%20be%20corrected%20for%20Hard-Iron%20and%20Soft-Iron%20effects.%20If%20you%20are%20interested%20in%20more%20complex%20algorithms%20you%20may%20refer%20to%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Fmagnetometers%2Fsample-data-sets-for-inertial-and-magnetic-sensors%2Ffreescale-e-compass-software%3AE-Compass%3Ffsrch%3D1%26amp%3Bsr%3D3%26amp%3BpageNum%3D1%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20title%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Fmagnetometers%2Fsample-data-sets-for-inertial-and-magnetic-sensors%2Ffreescale-e-compass-software%3AE-Compass%3Ffsrch%3D1%26amp%3Bsr%3D3%26amp%3BpageNum%3D1%22%20target%3D%22_blank%22%3ENXP%20E-Compass%20Software%3C%2FA%3E.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EAs%20an%20alternative%2C%20a%20method%20to%20calibrate%20the%20hard%20iron%20offset%20is%20rotating%20the%20MAG3110%20in%20a%20figure%20of%20%3CEM%3Eeight%20twisting%20motions%3C%2FEM%3E%20for%20a%20few%20seconds%2C%20record%20the%20minimum%20and%20maximum%20magnetometer%20readings%2C%20compute%20the%20corresponding%20offset%20values%20by%20using%20the%20min%2Fmax%20averaging%20and%20then%20either%20subtract%20these%20offset%20values%20from%20the%20current%20magnetometer%20measurements%20or%20write%20them%20in%20the%20user%20%3CSTRONG%3Eoffset%20registers%3C%2FSTRONG%3E%20with%20CTRL_REG2%5BRAW%5D%20%3D%200.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22eight.jpg%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22eight.jpg%22%20style%3D%22width%3A%20506px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F32458i15CD212CFDFE43BB%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22eight.jpg%22%20alt%3D%22eight.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThe%20hard%20iron%20offset%20calibration%20is%20done%20as%20follow%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CPRE%20class%3D%22line-numbers%20language-csharp%22%3E%3CCODE%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%20Xout_16_bit_avg%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20Yout_16_bit_avg%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20Zout_16_bit_avg%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%20Xout_16_bit_max%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20Yout_16_bit_max%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20Zout_16_bit_max%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%20Xout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20Yout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20Zout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%20i%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E0%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22keyword%20token%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3Ei%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E200%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Calibration%20process%20~10s%20(200%20samples%20*%201%2F20Hz)%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EDataReady%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20DataReady%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22token%20function%22%3EI2C_ReadMultiRegisters%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OUT_X_MSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E6%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Read%20data%20output%20registers%200x01-0x06%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Xout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E0%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%2016-bit%20X-axis%20output%20value%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Yout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E2%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E3%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%2016-bit%20Y-axis%20output%20value%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Zout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E4%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E5%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%2016-bit%20Z-axis%20output%20value%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3Ei%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Xout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Xout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Xout_16_bit_min%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Xout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Yout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Yout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Yout_16_bit_min%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Yout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Zout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Zout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Zout_16_bit_min%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Zout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Check%20to%20see%20if%20current%20sample%20is%20the%20maximum%20or%20minimum%20X-axis%20value%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EXout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%20Xout_16_bit_max%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3EXout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Xout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EXout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%20Xout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3EXout_16_bit_min%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Xout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Check%20to%20see%20if%20current%20sample%20is%20the%20maximum%20or%20minimum%20X-axis%20value%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EYout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%20Yout_16_bit_max%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3EYout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Yout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EYout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%20Yout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3EYout_16_bit_min%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Yout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Check%20to%20see%20if%20current%20sample%20is%20the%20maximum%20or%20minimum%20X-axis%20value%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EZout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%20Zout_16_bit_max%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3EZout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Zout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EZout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%20Zout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3EZout_16_bit_min%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20Zout_16_bit%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20i%3CSPAN%20class%3D%22operator%20token%22%3E%2B%2B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%0A%0AXout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EXout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%2B%3C%2FSPAN%3E%20Xout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%2F%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E2%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20X-axis%20hard-iron%20offset%3C%2FSPAN%3E%0AYout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EYout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%2B%3C%2FSPAN%3E%20Yout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%2F%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E2%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Y-axis%20hard-iron%20offset%3C%2FSPAN%3E%0AZout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EZout_16_bit_max%20%3CSPAN%20class%3D%22operator%20token%22%3E%2B%3C%2FSPAN%3E%20Zout_16_bit_min%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%2F%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E2%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Z-axis%20hard-iron%20offset%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Left-shift%20by%20one%20as%20magnetometer%20offset%20registers%20are%2015-bit%20only%2C%20left%20justified%3C%2FSPAN%3E%0AXout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0AYout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0AZout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20CTRL_REG1%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x00%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Standby%20mode%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Set%20Offset%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OFF_X_LSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EXout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0xFF%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OFF_X_MSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EXout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0xFF%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OFF_Y_LSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EYout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0xFF%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OFF_Y_MSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EYout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0xFF%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OFF_Z_LSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EZout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0xFF%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OFF_Z_MSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EZout_16_bit_avg%20%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0xFF%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22token%20function%22%3EI2C_WriteRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20CTRL_REG1%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x11%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%26nbsp%3B%20Active%20mode%20again%3C%2FSPAN%3E%0A%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%3CSPAN%20class%3D%22line-numbers-rows%22%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CH2%20id%3D%22toc-hId-1751110625%22%20id%3D%22toc-hId-1751110625%22%20id%3D%22toc-hId--1626530098%22%3E4.%20Output%20data%20reading%20using%20an%20interrupt%20technique.%3C%2FH2%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EAt%20the%20ISR%2C%20the%20interrupt%20flag%20is%20clear%20and%20the%20%3CEM%3EDataReady%3C%2FEM%3E%20variable%20is%20set%20in%20order%20to%20know%20that%20a%20new%20magnetic%20measurement%20is%20ready.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CPRE%20class%3D%22line-numbers%20language-csharp%22%3E%3CCODE%3E%3CSPAN%20class%3D%22keyword%20token%22%3Evoid%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22token%20function%22%3EPORTD_IRQHandler%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20PORTD_PCR4%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20PORT_PCR_ISF_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Clear%20the%20interrupt%20flag%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20DataReady%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%3CSPAN%20class%3D%22line-numbers-rows%22%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CH2%20id%3D%22toc-hId--56343838%22%20id%3D%22toc-hId--56343838%22%20id%3D%22toc-hId-860982735%22%3E5.%20Conversion%20of%20the%20output%20values%3C%2FH2%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20output%20values%20from%20magnetometer%20are%20converted%20to%20signed%2016-bit%20integer%20values%20and%20afterwards%20to%20real%20values%20in%20microtesla%20(%C2%B5T).%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CPRE%20class%3D%22line-numbers%20language-csharp%22%3E%3CCODE%3E%3CSPAN%20class%3D%22keyword%20token%22%3Efor%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3E%20%0A%26nbsp%3B%26nbsp%3B%20%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EDataReady%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%0A%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20DataReady%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%0A%26nbsp%3B%26nbsp%3B%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22token%20function%22%3EI2C_ReadMultiRegisters%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMAG3110_I2C_ADDRESS%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20OUT_X_MSB%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E6%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%2C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Read%20data%20output%20registers%200x01-0x06%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%2016-bit%20magnetometer%20data%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Xout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E0%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%2016-bit%20X-axis%20output%20value%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Yout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E2%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E3%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%2016-bit%20Y-axis%20output%20value%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Zout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eshort%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3EMagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E4%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E8%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%7C%3C%2FSPAN%3E%20MagData%3CSPAN%20class%3D%22punctuation%20token%22%3E%5B%3C%2FSPAN%3E%3CSPAN%20class%3D%22number%20token%22%3E5%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%2016-bit%20Z-axis%20output%20value%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Magnetometer%20data%20converted%20to%20microteslas%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Xout_uT%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Efloat%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3EXout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%2F%3C%2FSPAN%3E%20SENSITIVITY%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%20X-axis%20output%20magnetic%20value%20in%20uT%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Yout_uT%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Efloat%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3EYout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%2F%3C%2FSPAN%3E%20SENSITIVITY%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%20Y-axis%20output%20magnetic%20value%20in%20uT%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Zout_uT%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Efloat%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3EZout_16_bit%20%3CSPAN%20class%3D%22operator%20token%22%3E%2F%3C%2FSPAN%3E%20SENSITIVITY%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Compute%20Z-axis%20output%20magnetic%20value%20in%20uT%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%0A%20%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%E2%80%8D%3CSPAN%20class%3D%22line-numbers-rows%22%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CH2%20id%3D%22toc-hId--1863798301%22%20id%3D%22toc-hId--1863798301%22%20id%3D%22toc-hId--946471728%22%3E6.%20FreeMASTER%3C%2FH2%3E%3CP%3E%3C%2FP%3E%3CP%3EFreeMASTER%20is%20a%20user-friendly%20real-time%20debug%20monitor%20and%20data%20visualization%20tool%20that%20you%20can%20use%20for%20any%20application%20development%20and%20information%20management.%20In%20this%20case%2C%20it%20is%20used%20in%20order%20to%20visualize%20the%20magnetic%20data.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22FreeMaster.jpg%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22FreeMaster.jpg%22%20style%3D%22width%3A%20989px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F32358iEED83181C2663E7D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22FreeMaster.jpg%22%20alt%3D%22FreeMaster.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%22%3EIn%20case%20you%20have%20%3CSTRONG%3Eproblems%3C%2FSTRONG%3E%20with%20the%20communication%20port%2C%20please%20go%20to%20%3CSPAN%20style%3D%22font-family%3A%20'Arial'%2Csans-serif%3B%22%3E%3CEM%3EProject%20%2F%20Options%E2%80%A6%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%22%3ESelect%20%3CSPAN%20style%3D%22font-family%3A%20'Arial'%2Csans-serif%3B%22%3E%3CEM%3EPlug-in%20Module%3C%2FEM%3E%3C%2FSPAN%3E%20and%20choose%20the%20%3CEM%3E%3CSPAN%20style%3D%22font-family%3A%20'Arial'%2Csans-serif%3B%22%3EFreeMASTER%20BDM%20Communication%20Plug-in%3C%2FSPAN%3E%20%3C%2FEM%3Eoption.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22options.jpg%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22options.jpg%22%20style%3D%22width%3A%20489px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F32468iCF863F340264401E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22options.jpg%22%20alt%3D%22options.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%22%3ESelect%20configure%20and%20make%20sure%20the%20%3CSPAN%20style%3D%22font-family%3A%20'Arial'%2Csans-serif%3B%22%3E%3CEM%3EP%26amp%3BE%20Kinetis%3C%2FEM%3E%3C%2FSPAN%3E%20is%20selected.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%22%3ESelect%20%3CSPAN%20style%3D%22font-family%3A%20'Arial'%2Csans-serif%3B%22%3E%3CEM%3EOK%3C%2FEM%3E%3C%2FSPAN%3E%20and%20Start%20the%20communication.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EPlease%20find%20attached%20the%20complete%20source%20code%2C%20including%20the%20FreeMASTER%20project.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EYou%20are%20invited%20to%20take%20part%20of%20the%20NXP%20community%20where%20you%20can%20post%20all%20your%20questions%20and%20you%20may%20find%20useful%20material%20for%20your%20projects.%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EI%20hope%20you%20find%20useful%20and%20funny%20this%20sample%20project.%20Any%20suggestion%20will%20be%20appreciated.%20%3CIMG%20id%3D%22smileyhappy%22%20class%3D%22emoticon%20emoticon-smileyhappy%22%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fi%2Fsmilies%2F16x16_smiley-happy.png%22%20alt%3D%22Smiley%20Happy%22%20title%3D%22Smiley%20Happy%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EBest%20Regards%2C%3C%2FP%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EDavid%3C%2FP%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1100619%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EMagnetic%20Sensors%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
No ratings
Version history
Last update:
‎09-10-2020 01:39 AM
Updated by: