A motion sensor, comprising: a magnetic field sensing element (104a; 104b; 104c) configured to generate a magnetic field signal indicative of a magnetic field associated with an object; and a state processor configured to receive a signal representative of the magnetic field signal, wherein the state processor is configured to generate a STATE_SM signal indicative of a plurality of states associated with the magnetic field signal, wherein the plurality of states is indicative of a respective range of signal values of the magnetic field signal, wherein the STATE_SM signal comprises a plurality of first direction state transitions and a plurality of second direction state transitions, wherein the plurality of first direction state transitions and the plurality of second direction state transitions comprise state transition chatter, characterised in that the state processor comprises: a state peak logic module configured to receive the STATE_SM signal and configured to generate a STATE_PEAK signal related to the STATE_SM signal, wherein the STATE_PEAK signal comprises a plurality of first direction state peak transitions and a plurality of second direction state peak transitions, wherein the state peak logic module is further configured receive a POSCOMP_PK signal generated inside the motion sensor and being a two-state signal having state transitions that occur when a state represented by the STATE_PEAK signal differs from a state represented by the STATE_SM signal by a predetermined number of states, and wherein the state peak logic module comprises a state peak logic processor configured, if the POSCOMP_PK signal is equal to a first state, and a state value of the STATE_SM signal is greater than a state value of the STATE_PEAK signal, to set a state value of the STATE_PEAK signal to equal a state value of the STATE_SM signal, and if the POSCOMP_PK signal is equal to a second different state, and a state value of the STATE_SM signal is less than a state value of the STATE_PEAK signal, to also set a state value of the STATE_PEAK signal to equal a state value of the STATE_SM signal, whereby the plurality of first direction state peak transitions and the plurality of second direction state peak transitions have reduced state transition chatter. a magnetic field sensing element (104a; 104b; 104c) configured to generate a magnetic field signal indicative of a magnetic field associated with an object; and a state processor configured to receive a signal representative of the magnetic field signal, wherein the state processor is configured to generate a STATE_SM signal indicative of a plurality of states associated with the magnetic field signal, wherein the plurality of states is indicative of a respective range of signal values of the magnetic field signal, wherein the STATE_SM signal comprises a plurality of first direction state transitions and a plurality of second direction state transitions, wherein the plurality of first direction state transitions and the plurality of second direction state transitions comprise state transition chatter, characterised in that the state processor comprises: a state peak logic module configured to receive the STATE_SM signal and configured to generate a STATE_PEAK signal related to the STATE_SM signal, wherein the STATE_PEAK signal comprises a plurality of first direction state peak transitions and a plurality of second direction state peak transitions, wherein the state peak logic module is further configured receive a POSCOMP_PK signal generated inside the motion sensor and being a two-state signal having state transitions that occur when a state represented by the STATE_PEAK signal differs from a state represented by the STATE_SM signal by a predetermined number of states, and wherein the state peak logic module comprises a state peak logic processor configured, if the POSCOMP_PK signal is equal to a first state, and a state value of the STATE_SM signal is greater than a state value of the STATE_PEAK signal, to set a state value of the STATE_PEAK signal to equal a state value of the STATE_SM signal, and if the POSCOMP_PK signal is equal to a second different state, and a state value of the STATE_SM signal is less than a state value of the STATE_PEAK signal, to also set a state value of the STATE_PEAK signal to equal a state value of the STATE_SM signal, whereby the plurality of first direction state peak transitions and the plurality of second direction state peak transitions have reduced state transition chatter.