The invention relates to a method for authorizing an update of a switching threshold of a magnetic field sensor for a thermal engine of a motor vehicle in order to ensure immunity of the sensor to external magnetic disturbances. The sensor detects variations in the magnetic field induced by a passage of the teeth of a target near the sensor by developing a magnetic signal exhibiting oscillations, some of which may be due to magnetic disturbances and not to be taken into account for the updating by the sensor of the switching threshold (SC) recalculated as a function of a detected amplitude of at least two consecutive oscillations of the magnetic field. An update of the switching threshold is suspended when an oscillation frequency calculated between said at least two consecutive oscillations is greater than a maximum oscillation frequency calculated from a predetermined motor rotation speed and the number of teeth on target. Abstract figure: Figure 2
展开▼