I was able to reliably recover readings from the Parallax 360 Servo Feedback pin using smarten mode %10000 (Continuous states are counted in clock cycles
Here is the inside loop:
loop outh #sync 'sync at the beginning
rqpin temp, #servoPin wc 'get PREVIOUS high time or low time
if_NC waitx #200
if_NC jmp #loop 'wait until it returns a "high" value
wypin #10, #SYellow 'process high
wrlong temp, HiAdrs
L2 rqpin temp, #ServoPin wc 'now we look for a LOW value
if_C waitx #200
if_C jmp #L2
if_NC wypin #10, #SGreen 'process low
if_NC wrlong temp, LoAdrs
In mode %10000, the pin is continuously monitored. When an edge is detected, the count is placed in the Z buffer and cleared and the state corresponding to the count is placed in the C-flag buffer. These buffers are maintained until the next edge and can be read at any time.
The program MUST read a high period and then the corresponding LOW period. If it reads a LOW period followed by a HIGH, or if there are intervening states, the results are not valid, particularly if the servo crosses zero. In the method where the program watches for edges (this is what I did on P1), it must wait until it detects a LOW-to-HIGH transition before it starts timing. This can mean as much as nearly two full feedback cycles to acquire timing in the case where the program begins searching during a HIGH period. With the P2, the program can take advantage of the buffers and never spend more than one full feedback cycles to acquire timing.
Here is the code to set the mode
timerMode = %0100_000000000_00_10000_0 'continuous states are counted (schmitt trigger)
wrpin MMode, #ServoPin 'set smart pin timer mode
dirh #ServoPin 'Remove Reset
Oddly, I absolutely had to invoke the Schmitt trigger in the smart pin configuration. If not, there were intermittent glitches on the HIGH-to-LOW transitions which would result in spurious readings of 1 or 2. I am unable to explain the glitches; I have never seen them before and do not see them with the Schmitt trigger. Is it remotely possible the smart pin is causing them?
The whole test program in attached.
Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.