pyfastservo adc: Add helper fn for phase shifting the dac ddr clock
This commit is contained in:
parent
9f2e609b6e
commit
bbe09de52c
|
@ -92,7 +92,19 @@ def mmcm_rst():
|
|||
while not(read_frame() & 0x10):
|
||||
print(f"Waiting for MMCM to lock")
|
||||
time.sleep(0.001)
|
||||
|
||||
|
||||
def inc_ddr_clk_phase():
|
||||
curr_cfg = read_from_memory(ADC_AFE_CTRL_ADDR, 1)[0] & 0x1F
|
||||
write_to_memory(ADC_AFE_CTRL_ADDR, 0x40 | curr_cfg) # Set MMCM Phase Shift to be INC
|
||||
write_to_memory(ADC_AFE_CTRL_ADDR, 0x60 | curr_cfg) # Assert MMCM Phase Shift EN High
|
||||
write_to_memory(ADC_AFE_CTRL_ADDR, curr_cfg) # Deassert MMCM Phase Shift EN High
|
||||
|
||||
def dec_ddr_clk_phase():
|
||||
curr_cfg = read_from_memory(ADC_AFE_CTRL_ADDR, 1)[0] & 0x1F
|
||||
write_to_memory(ADC_AFE_CTRL_ADDR, 0x00 | curr_cfg) # Set MMCM Phase Shift to be DEC
|
||||
write_to_memory(ADC_AFE_CTRL_ADDR, 0x20 | curr_cfg) # Assert MMCM Phase Shift EN High
|
||||
write_to_memory(ADC_AFE_CTRL_ADDR, curr_cfg) # Deassert MMCM Phase Shift EN High
|
||||
|
||||
def find_edge():
|
||||
prev_frame = read_frame()
|
||||
for tap_delay in range(32):
|
||||
|
@ -131,6 +143,36 @@ def enable_adc_afe(ch1_x10=False, ch2_x10=False):
|
|||
print(f"ADC_AFE_CTRL: 0x{afe_ctrl:02X}")
|
||||
return afe_ctrl
|
||||
|
||||
def search_edge():
|
||||
for tap_delay in range(32):
|
||||
print(f"iDelay to: {tap_delay}")
|
||||
write_to_memory(ADC_DELAY_ADDR, tap_delay)
|
||||
time.sleep(1)
|
||||
current_frame = read_frame()
|
||||
print(f"Tap delay: {tap_delay}, Current frame: 0x{current_frame:02x}")
|
||||
print_adc_channels()
|
||||
|
||||
def print_adc_channel(ch):
|
||||
if ch == 0:
|
||||
adc_ch0 = read_adc_channel(ADC_CH0_HIGH_ADDR, ADC_CH0_LOW_ADDR)
|
||||
print(f"Final ADC_CH0: 0x{adc_ch0:04x}")
|
||||
if ch == 1:
|
||||
adc_ch1 = read_adc_channel(ADC_CH1_HIGH_ADDR, ADC_CH1_LOW_ADDR)
|
||||
print(f"Final ADC_CH1: 0x{adc_ch1:04x}")
|
||||
|
||||
def find_min_max_ch(ch):
|
||||
test = []
|
||||
for i in range(100):
|
||||
if ch == 0:
|
||||
test.append(read_adc_channel(ADC_CH0_HIGH_ADDR, ADC_CH0_LOW_ADDR))
|
||||
else:
|
||||
test.append(read_adc_channel(ADC_CH1_HIGH_ADDR, ADC_CH1_LOW_ADDR))
|
||||
print("ch", ch, hex(test[-1]))
|
||||
print("Min:", hex(min(test)))
|
||||
print("Max:", hex(max(test)))
|
||||
print("Diff:", hex(max(test)-min(test)))
|
||||
|
||||
|
||||
def configure_ltc2195():
|
||||
spi = spidev.SpiDev()
|
||||
try:
|
||||
|
@ -166,6 +208,15 @@ def configure_ltc2195():
|
|||
# FIXME: AFE Gain 1x is not functional on that batch of fast servo under development
|
||||
enable_adc_afe(ch1_x10=1, ch2_x10=1)
|
||||
|
||||
#find_min_max_ch(0)
|
||||
#find_min_max_ch(1)
|
||||
|
||||
#for i in range(10):
|
||||
# print_adc_channel(0)
|
||||
|
||||
#for i in range(10):
|
||||
# print_adc_channel(1)
|
||||
|
||||
finally:
|
||||
spi.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue