A motion sensor for detecting a motion of an object comprises: a magnetic field sensing element for generating a magnetic field signal having cycles; a state processor coupled to the magnetic field sensor for generating a PPEAK or NPEAK signal indicative of positive or negative peaks of the cycles of the magnetic field signal; and a vibration processor comprising a peak update jump processor for comparing a first value of the PPEAK or NPEAK signal for a first cycle with a second respective value of the PPEAK or NPEAK signal for a second later cycle, and for changing a state of a PEAK_CLAMP_FLAG or a PEAK_IN FLAG signal, indicative of an increase in magnitude of the PPEAK or NPEAK signal by more than a first determined amount, and wherein the change of state of the PEAK_IN flag signal is indicative of a decrease of magnitude of the PPEAK or NPEAK signal by more than a second determined amount, wherein particular states of the PEAK_CLAMP_FLAG and the PEAK_IN_FLAG signal are representative of a magnitude of the magnetic field signal being too large or too small, respectively.
Motion sensor, method and computer-readable storage medium for detecting a motion of an object