From 382e8467d9f4e571403215192f37190911c8f1c9 Mon Sep 17 00:00:00 2001 From: linuswck Date: Fri, 8 Nov 2024 12:41:07 +0800 Subject: [PATCH] pyfastservo adc: Fix find edge bug - Fix: if frame changed at 31 tap delay, edge would not get detected --- fast-servo/pyfastservo/adc.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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