A seven-element model corrects for hard iron and soft iron interference. Freescale also offers a 10-element model, but you must contact the company for more information. The eCompass code typically requires about 15 kilobytes of Flash memory and 5 kilobytes of RAM.
You might wonder about the terms "soft iron" and "hard iron." The accuracy of an eCompass-based device depends greatly on the calculation of and subtraction in software of stray magnetic fields both within and nearby the magnetometer on a PCB. By convention, engineers separate these effects into fixed fields -- hard iron effects -- and fields induced by geomagnetism -- soft iron effects.
Soft iron effects arise from distortions in the magnetic field at the sensor caused by nearby nonmagnetic devices such as capacitors and shields. These components cause a distortion that varies with their orientation in the Earth's magnetic field. As a result, the accelerometers need to determine sensor orientation with respect to Earth's gravity.
Hard iron effects arise from permanent-magnet-type components such as audio speakers, buzzers, or vibrator-motors on a circuit board. For more information about these effects, read Freescale's application note AN4247, "Layout Recommendations for PCBs Using a Magnetometer Sensor."
Engineers can work easily with the sensors and software by purchasing a $99, three-board package (RD4247MAG3110) that includes a sensor module, an interface board, and a USB-based board. Freescale distributors should have the board in stock, and you can click here for the kit's user guide. Freescale plans to send me a board set soon, and I'll report on how it works.