Skip to content
Snippets Groups Projects
Commit 4e317e3c authored by Gijs Schoonderbeek's avatar Gijs Schoonderbeek
Browse files

Added readout of loss of lock (LOL)

parent 4a5e88ac
No related branches found
No related tags found
No related merge requests found
......@@ -26,15 +26,15 @@ else:
DEBUG = False
I2CBUSNR=5
sleep_time = 0.15
SET_PLL = True
SET_PLL = False #True
READ_LOCK = True
READ_ALL = False
CHECK_EEPROM = False
PWR_RST = False #True #False
READ_SENSOR = True
READ_SENSOR = False #True
READ_REGS = False #True
CLK_FREQ = '200MHz' #'160MHz'
CLK_FREQ = '160MHz'
dev_i2c_eeprom = I2C(0x50)
dev_i2c_eeprom.bus_nr = I2CBUSNR
......@@ -151,11 +151,11 @@ def setup_pll(pll_frequency='200MHz') :
if pll_frequency == '160MHz':
print("Set PLL to 160 MHz mode")
pll_address = PLL_160M
I2C_device.write_bytes(0x03, 0x0F)
I2C_device.write_bytes(0x03, 0x08)
else:
print("Set PLL to 200 MHz mode")
pll_address=PLL_200M
I2C_device.write_bytes(0x03, 0xFF)
I2C_device.write_bytes(0x03, 0x28)
Write_byte_PLL(0x03, 0x0C, pll_address)
sleep(0.5)
Write_byte_PLL(0x03, 0x08, pll_address)
......@@ -290,6 +290,31 @@ def read_temp():
else:
print("Error reading tempeature")
def read_lol(pll_frequency='200MHz'):
I2C_IO_device_A = I2C(0x20, BUSNR=I2CBUSNR)
I2C_IO_device_A.write_bytes(0x06, 0x2C) # '0' is output
I2C_IO_device_A.write_bytes(0x07, 0x00) # '0' is output
I2C_IO_device_B = I2C(0x21, BUSNR=I2CBUSNR)
I2C_IO_device_B.write_bytes(0x06, 0x2C) # '0' is output
I2C_IO_device_B.write_bytes(0x07, 0xFF) # '0' is output
ack, ret_value = I2C_IO_device_B.read_bytes(0x01, 1)
status_reg = int(ret_value,16)
if (pll_frequency=='200MHz') & ((status_reg & 0x10) > 0):
print("lost lock 200MHz")
if ((status_reg & 0x20) > 0) & (pll_frequency=='160MHz'):
print("lost lock 160MHz")
ack, ret_value = I2C_IO_device_A.read_bytes(0x01, 1)
old_reg = int(ret_value,16)
I2C_IO_device_A.write_bytes(0x03, (old_reg | 0x10)) # '0' is output
sleep(1)
I2C_IO_device_A.write_bytes(0x03, (old_reg & 0xEF)) # '0' is output
#if READ_REGS:
# read_all_regs_pll(CLK_FREQ)
......@@ -329,3 +354,4 @@ if READ_ALL:
if READ_SENSOR:
apsct_sensors()
read_lol(CLK_FREQ)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment