Skip to content
Snippets Groups Projects

Apsct production

1 file
+ 20
4
Compare changes
  • Side-by-side
  • Inline
+ 20
4
@@ -158,7 +158,7 @@ class PllClass:
@@ -158,7 +158,7 @@ class PllClass:
for clk in range(2):
for clk in range(2):
Write_data = 0x02 | (0 << CS) | (clk << SCLK) | (int(bit) << SDI)
Write_data = 0x02 | (0 << CS) | (clk << SCLK) | (int(bit) << SDI)
self.dev_i2c_pll.write_bytes(0x02, Write_data)
self.dev_i2c_pll.write_bytes(0x02, Write_data)
time.sleep(sleep_time)
sleep(sleep_time)
read_bit = ''
read_bit = ''
for cnt in range(8*nof_bytes):
for cnt in range(8*nof_bytes):
for clk in [0, 1]: # Read after rizing edge
for clk in [0, 1]: # Read after rizing edge
@@ -219,6 +219,19 @@ class PllClass:
@@ -219,6 +219,19 @@ class PllClass:
stri = "Reg nr 0x{:0>2x} value: 0x{:0>2x}".format(cnt, int(ret_value[start:start+8], 2))
stri = "Reg nr 0x{:0>2x} value: 0x{:0>2x}".format(cnt, int(ret_value[start:start+8], 2))
print(stri)
print(stri)
 
def read_lock(self):
 
#
 
# Read lock status
 
#
 
ret_value = self.Read_byte_PLL(0x00, nof_bytes = 1)
 
status_pll = int(ret_value,2)
 
if status_pll == 0x04:
 
print("PLL in lock")
 
elif (status_pll & 0x10) > 0:
 
print("Not Locked --> No 10 MHz ref")
 
else:
 
print("Not locked --> PLL Error")
 
def read_lol(self, pll_frequency='200MHz'):
def read_lol(self, pll_frequency='200MHz'):
#
#
# Read loss of lock status
# Read loss of lock status
@@ -233,9 +246,9 @@ class PllClass:
@@ -233,9 +246,9 @@ class PllClass:
ack, ret_value = I2C_IO_device_B.read_bytes(0x01, 1)
ack, ret_value = I2C_IO_device_B.read_bytes(0x01, 1)
status_reg = int(ret_value, 16)
status_reg = int(ret_value, 16)
if (pll_frequency == '200MHz') & ((status_reg & 0x10) > 0):
if (pll_frequency == '200MHz') & ((status_reg & 0x10) > 0):
print("lost lock 200MHz")
print("200MHz has lost lock")
if ((status_reg & 0x20) > 0) & (pll_frequency == '160MHz'):
if ((status_reg & 0x20) > 0) & (pll_frequency == '160MHz'):
print("lost lock 160MHz")
print("160MHz has last lock")
ack, ret_value = I2C_IO_device_A.read_bytes(0x01, 1)
ack, ret_value = I2C_IO_device_A.read_bytes(0x01, 1)
old_reg = int(ret_value, 16)
old_reg = int(ret_value, 16)
I2C_IO_device_A.write_bytes(0x03, (old_reg | 0x10)) # '0' is output
I2C_IO_device_A.write_bytes(0x03, (old_reg | 0x10)) # '0' is output
@@ -287,7 +300,9 @@ class EepromClass:
@@ -287,7 +300,9 @@ class EepromClass:
return False
return False
else:
else:
ret_ack, ret_value = self.dev_i2c_eeprom.read_bytes(address, nof_bytes)
ret_ack, ret_value = self.dev_i2c_eeprom.read_bytes(address, nof_bytes)
str_return = bytes.fromhex(ret_value[:nof_bytes * 2]).decode('UTF-8')
ret_value = bytes.fromhex(ret_value[:nof_bytes * 2])
 
#print(" ret value = {}".format(ret_value))
 
str_return = ret_value.decode('UTF-8')
return str_return
return str_return
def wr_rd_eeprom(self, value="APSPU-1", address=0):
def wr_rd_eeprom(self, value="APSPU-1", address=0):
@@ -300,6 +315,7 @@ class EepromClass:
@@ -300,6 +315,7 @@ class EepromClass:
#
#
if self.write_eeprom(value, address=0):
if self.write_eeprom(value, address=0):
ret_value = self.read_eeprom(address=0, nof_bytes=len(value))
ret_value = self.read_eeprom(address=0, nof_bytes=len(value))
 
print(ret_value)
stri = "Wrote to EEPROM register 0x{2:x} : {0}, Read from EEPROM: {1}".format(value, ret_value, address)
stri = "Wrote to EEPROM register 0x{2:x} : {0}, Read from EEPROM: {1}".format(value, ret_value, address)
print(stri)
print(stri)
if ret_value == value:
if ret_value == value:
Loading