A method and system for calibrating a magnetic compass and/or verifying a
compass calibration, using a calibration magnetic field produced by a
field-generating coil within the magnetic compass is described. The
field-generating coil is located near magnetometers within the magnetic
compass. Passing a self-trimming current through the coil produces a
magnetic field that acts on the magnetometers. Samples of an output
signal from each magnetometer are taken to obtain digital values that
indicate the output signal from each magnetometer. The digital values are
used by a processor to determine one or more calibration coefficient for
using calibrating the magnetic compass. The samples of the output signals
are taken when a self-trimming current is passing through the coil and
when the self-trimming current is not passing through the coil.
Calibration of the compass occurs by applying the one or more calibration
coefficients to subsequent signals that indicate the output signals of
one or more of the magnetometers.