forked from M-Labs/nix-servo
test write_ramp
This commit is contained in:
parent
0927824c61
commit
e7549b7392
|
@ -124,6 +124,12 @@ def write_sample(channel, sample):
|
|||
for addr, value in zip(addresses, values):
|
||||
write_to_memory(addr, value)
|
||||
|
||||
def write_ramp():
|
||||
signal = [i for i in range(16384)]
|
||||
|
||||
for value in signal:
|
||||
write_sample(0, value)
|
||||
|
||||
|
||||
def configure_ad9117():
|
||||
spi = spidev.SpiDev()
|
||||
|
@ -148,25 +154,27 @@ def configure_ad9117():
|
|||
power_down(1, False)
|
||||
manual_override(True)
|
||||
|
||||
# Write sample value 0x1FFF to both channels
|
||||
sample_value = 0x1FFF
|
||||
write_sample(0, sample_value) # Write to channel 0
|
||||
write_sample(1, sample_value) # Write to channel 1
|
||||
write_ramp()
|
||||
|
||||
print(f"Sample value 0x{sample_value:04X} written to both channels")
|
||||
# # Write sample value 0x1FFF to both channels
|
||||
# sample_value = 0x1FFF
|
||||
# write_sample(0, sample_value) # Write to channel 0
|
||||
# write_sample(1, sample_value) # Write to channel 1
|
||||
|
||||
# Read back the values from memory
|
||||
ch0_high = read_from_memory(CH0_HIGH_WORD_ADDR, 1)[0]
|
||||
ch0_low = read_from_memory(CH0_LOW_WORD_ADDR, 1)[0]
|
||||
ch1_high = read_from_memory(CH1_HIGH_WORD_ADDR, 1)[0]
|
||||
ch1_low = read_from_memory(CH1_LOW_WORD_ADDR, 1)[0]
|
||||
# print(f"Sample value 0x{sample_value:04X} written to both channels")
|
||||
|
||||
# Reconstruct the 14-bit values
|
||||
ch0_value = (ch0_high << 8) | ch0_low
|
||||
ch1_value = (ch1_high << 8) | ch1_low
|
||||
# # Read back the values from memory
|
||||
# ch0_high = read_from_memory(CH0_HIGH_WORD_ADDR, 1)[0]
|
||||
# ch0_low = read_from_memory(CH0_LOW_WORD_ADDR, 1)[0]
|
||||
# ch1_high = read_from_memory(CH1_HIGH_WORD_ADDR, 1)[0]
|
||||
# ch1_low = read_from_memory(CH1_LOW_WORD_ADDR, 1)[0]
|
||||
|
||||
print(f"Read back value for channel 0: 0x{ch0_value:04X}")
|
||||
print(f"Read back value for channel 1: 0x{ch1_value:04X}")
|
||||
# # Reconstruct the 14-bit values
|
||||
# ch0_value = (ch0_high << 8) | ch0_low
|
||||
# ch1_value = (ch1_high << 8) | ch1_low
|
||||
|
||||
# print(f"Read back value for channel 0: 0x{ch0_value:04X}")
|
||||
# print(f"Read back value for channel 1: 0x{ch1_value:04X}")
|
||||
|
||||
print("AD9117 configuration completed successfully")
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue