Skip to content
Snippets Groups Projects
Commit 6f806ce0 authored by Gijs's avatar Gijs
Browse files

Working version

parent fc63aa0d
No related branches found
No related tags found
No related merge requests found
......@@ -196,7 +196,8 @@ class PllClass:
self.write_byte_pll(0x06, 0x01) # (divider_b & 0x00FF))
self.write_byte_pll(0x07, 0x00) # No LOR
# self.write_byte_pll(0x08, 0x3B) # Charge pump normal + Status bit
self.write_byte_pll(0x08, 0x43) # Charge pump normal + Status bit
self.write_byte_pll(0x08, 0x47) # Charge pump normal + Status bit
# self.write_byte_pll(0x08, 0x43) # Charge pump normal + Status bit
# self.write_byte_pll(0x09, (charge_pump_current & 0x7) << 4)
self.write_byte_pll(0x09, 0x50) # (charge_pump_current & 0x7) << 4)
# self.write_byte_pll(0x0A, 0x00) # Fixed Divide 1
......@@ -237,10 +238,10 @@ class PllClass:
status_pll = int(ret_value, 16) & 0x04
if status_pll:
self.lock = True
stri = f"PLL is in lock"
stri = f"OK PLL is in lock"
else:
self.lock = False
stri = f"PLL is not locked"
stri = f"Error PLL is not locked"
print(stri)
return self.lock
......@@ -251,14 +252,16 @@ class PllClass:
i2_c_io_device_a = I2C(0x20, BUSNR=I2CBUSNR)
i2_c_io_device_a.write_bytes(0x06, 0x2C) # '0' is output
i2_c_io_device_a.write_bytes(0x07, 0x0F) # '0' is output
i2_c_io_device_b = I2C(0x21, BUSNR=I2CBUSNR)
i2_c_io_device_b.write_bytes(0x06, 0x2C) # '0' is output
i2_c_io_device_b.write_bytes(0x07, 0xFF) # '0' is output
ack, ret_value = i2_c_io_device_b.read_bytes(0x01, 1)
# i2_c_io_device_b = I2C(0x21, BUSNR=I2CBUSNR)
# i2_c_io_device_b.write_bytes(0x06, 0x2C) # '0' is output
# i2_c_io_device_b.write_bytes(0x07, 0xFF) # '0' is output
ack, ret_value = i2_c_io_device_a.read_bytes(0x01, 1)
status_reg = int(ret_value, 16)
lol = (status_reg & 0x04)
if lol:
print(f"{self.frequency} has lost lock")
print(f"Error {self.frequency} has lost lock")
else:
print(f"OK {self.frequency} has not lost lock")
ack, ret_value = i2_c_io_device_a.read_bytes(0x01, 1)
old_reg = int(ret_value, 16)
i2_c_io_device_a.write_bytes(0x03, (old_reg | 0x20)) # '0' is output
......@@ -505,6 +508,7 @@ class CcdId:
for pin in CCD_I2C.ID_PINS:
loc_id = loc_id * 2
bit = gpio.input(pin)
print(f"DEBUG.. Bit is {bit}")
loc_id = loc_id + bit
self.id = loc_id
return self.id
......@@ -530,9 +534,9 @@ def main():
Ccd.power(True)
sleep(1)
Ccd.pll.setup_pll()
# Ccd.pll.read_lol()
Ccd.pll.read_lock()
Ccd.pll.read_all_regs_pll()
Ccd.pll.read_lol()
# Ccd.pll.read_all_regs_pll()
Ccd.sensors.check_values()
# Ccd.eeprom.wr_rd_eeprom()
Ccd.ccd_id.check_id()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment