A magnetoresistive random access memory (MRAM) (900) that is susceptible
to a residual magnetic field is compensated during a write operation. A
first magnetic field (208) is applied to a memory cell during a first
time period, the first magnetic field having a first direction (y) and a
first magnitude. A second magnetic field (212) is applied to the memory
cell during a second time period and having a second direction (x) and a
second magnitude. A third magnetic field (702) is applied to the memory
cell during a third time period, wherein the third time period overlaps
at least a portion of the second time period, the third magnetic field
having a third direction (-y) which is approximately opposite to the
first direction of the first magnetic field. Currents are selectively
applied through conductors in the memory cell to apply the three magnetic
fields.