A counting scheme for a non-volatile counter includes automatic
point-of-reference generation implemented in a state machine. Two state
variables are used to store the rotation history of the magnet. One
variable stores the previous position of the magnet and the other stores
the net angle traveled by the magnet from the reference point. The first
pulse location after the counter is reset is automatically selected as
the reference point until the next counter reset. When the nonvolatile
counter counts up or down, i.e. when the magnet travels 360.degree. in
either direction, the second state variable is set to zero and the first
state variable is set to the reference point, indicating the start of a
new revolution.