Patent ID: 7558027

Claim:
A magnetic field sensor, comprising: a magnetic field detecting element that detects a magnitude of an external magnetic field based on an electric resistance of said magnetic field detecting element to sense current, the electric resistance being varied in accordance with the external magnetic field; an upper shield layer that is formed to cover said magnetic field detecting element; and a protective layer that is formed above said upper shield layer with respect to a direction of stacking, wherein said upper shield layer includes a first portion at least part of which covers a top surface of said magnetic field detecting element, and a second portion that covers said first portion, and, wherein said first portion has a larger absolute value of magnetostriction than said second portion; wherein said first portion has a positive value of magnetostriction, and extends in an approximately same cross section in a height direction of said magnetic field detecting element, and wherein said first portion is formed such that a dimension of said first portion in the height direction ranges between 1.5 times 200 times a dimension of said magnetic field detecting element in a track width direction, wherein said magnetic field detecting element comprises a magneto-resistive element which comprises a first ferromagnetic layer whose direction of magnetization is fixed with respect to the external magnetic field, a non-magnetic layer, and a second ferromagnetic layer whose direction of magnetization varies in accordance with the external magnetic field, and further comprising: a pair of bias layers for applying a bias magnetic field to said second ferromagnetic layer, said pair of bias layers being arranged on both sides of said magneto-resistive element with respect to the track width direction; a pair of lead electrodes for supplying the sense current to said magneto-resistive element, wherein each of said pair of lead electrodes covers at least a part of the corresponding bias layer; and an upper gap layer that is configured to cover surfaces of said pair of lead electrodes that are opposite to each other and said magneto-resistive element, said upper gap layer forming a recess between said pair of lead electrodes, wherein said first portion extends in the height direction such that said first portion fills only the recess.