A method of calibrating a magnetic field sensor (100; 800; 900) comprising: receiving, at a first input node of a processor configured to perform hyperbolic and/or trigonometric functions, a first signal set to a constant value from a first magnetic field sensing element ; while receiving the first signal at the first input node, receiving, at a second input node of the processor, a reference magnetic field having a known angle of rotation from a second magnetic field sensing element ; receiving, at the first input node of the processor, the reference magnetic field having a known angle of rotation from the first magnetic field sensing element ; while receiving the reference magnetic field at the first input node, receiving, at the second input node of the processor, a second signal set to a constant value from the second magnetic field sensing element ; measuring a difference between a transition of an output signal of an output of the processor while the magnetic field sensor experiences the magnetic field angle variation and an expected transition of the output of the processor in response to the first and second signals, and reference magnetic field, wherein the expected transitions occur when the magnetic field sensor elements detect the reference magnetic field and are properly aligned; and compensating for an orthogonality error of the first and/or second magnetic field sensing element by modifying an output of the first and/or second magnetic field sensing element by a function of the measured difference, wherein an axis of maximum sensitivity of the first magnetic field sensing element is substantially orthogonal to an axis of maximum sensitivity of the second magnetic field sensing elements so that the first signal from the first magnetic field sensing element and the second signal from the second magnetic field sensing element are quadrature signals. receiving, at a first input node of a processor configured to perform hyperbolic and/or trigonometric functions, a first signal set to a constant value from a first magnetic field sensing element ; while receiving the first signal at the first input node, receiving, at a second input node of the processor, a reference magnetic field having a known angle of rotation from a second magnetic field sensing element ; receiving, at the first input node of the processor, the reference magnetic field having a known angle of rotation from the first magnetic field sensing element ; while receiving the reference magnetic field at the first input node, receiving, at the second input node of the processor, a second signal set to a constant value from the second magnetic field sensing element ; measuring a difference between a transition of an output signal of an output of the processor while the magnetic field sensor experiences the magnetic field angle variation and an expected transition of the output of the processor in response to the first and second signals, and reference magnetic field, wherein the expected transitions occur when the magnetic field sensor elements detect the reference magnetic field and are properly aligned; and compensating for an orthogonality error of the first and/or second magnetic field sensing element by modifying an output of the first and/or second magnetic field sensing element by a function of the measured difference, wherein an axis of maximum sensitivity of the first magnetic field sensing element is substantially orthogonal to an axis of maximum sensitivity of the second magnetic field sensing elements so that the first signal from the first magnetic field sensing element and the second signal from the second magnetic field sensing element are quadrature signals. <EOS>