diff --git a/fast-servo/pyfastservo/adc.py b/fast-servo/pyfastservo/adc.py index 9cbe137..e2dbf19 100644 --- a/fast-servo/pyfastservo/adc.py +++ b/fast-servo/pyfastservo/adc.py @@ -87,21 +87,18 @@ def perform_bitslip(): def find_edge(): prev_frame = read_frame() - transition = False for tap_delay in range(32): write_to_memory(ADC_DELAY_ADDR, tap_delay) current_frame = read_frame() print(f"Tap delay: {tap_delay}, Current frame: 0x{current_frame:02x}") + print(f"prev_frame: 0x{prev_frame:02x}") if current_frame != prev_frame: - if not transition: - transition = True - else: - final_delay = (tap_delay // 2) + 2 - print(f"Edge detected; setting iDelay to: {final_delay}") - write_to_memory(ADC_DELAY_ADDR, final_delay) - return + final_delay = ((tap_delay+1) // 2) + 2 + print(f"Edge detected; setting iDelay to: {final_delay}") + write_to_memory(ADC_DELAY_ADDR, final_delay) + return prev_frame = current_frame