Patent ID: 7053607

Claim:
A method of compensating a temperature-dependent characteristic of a magnetic sensor which includes a magnetoresistive element whose resistance varies according to an external magnetic field, a first memory, a temperature detecting section for outputting, as a detection temperature, a temperature having a constant correlation with the temperature of said magnetoresistive element, and a heat generating element for generating heat when electrically energized; and which generates an output value corresponding to the external magnetic field on the basis of a resistance value of said magnetoresistive element; said magnetic sensor being adapted for incorporation in an electronic apparatus which includes a permanent magnet component, a casing, and a second memory, wherein said casing accommodates said magnetic sensor, said permanent magnet component, and said second memory; said method comprising the steps of: obtaining a first temperature of said magnetoresistive element on the basis of the detection temperature output from said temperature detecting section, and obtaining a first output value output from said magnetic sensor at the first temperature, before said magnetic sensor is accommodated in said casing; changing the electrically energized state of said heat generating element, before said magnetic sensor is accommodated in said casing; obtaining a second temperature of said magnetoresistive element on the basis of the detection temperature output from said temperature detecting section, and obtaining a second output value output from said magnetic sensor at the second temperature, before said magnetic sensor is accommodated in said casing; storing into said first memory a value corresponding to a ratio of a difference between said first and second output values to a difference between said first and second temperatures; storing into said second memory, as reference data, an offset value of the output value of said magnetic sensor and a detection temperature output from said temperature detecting section after said magnetic sensor is accommodated in said casing together with said permanent magnet component; and subsequently correcting the output value of said magnetic sensor on the basis of the value corresponding to the ratio stored in said first memory, the reference data stored in said second memory, and the detection temperature output from said temperature detecting section.