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

Tested power reset on HW

parent ba430d41
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ SET_PLL = True
READ_LOCK = True
READ_ALL = False
CHECK_EEPROM = True
PWR_RST = True
CLK_FREQ = '200MHz'
dev_i2c_eeprom = I2C(0x50)
......@@ -117,8 +118,7 @@ def Read_byte_PLL(reg_address, nof_bytes=1, ADDRESS=0x20 ):
def setup_pll(pll_frequency='200MHz') :
# Check PLL is in lock
I2C_device = I2C(0x20, BUSNR=I2CBUSNR)
I2C_device = I2C(0x20, BUSNR=I2CBUSNR) #clock selection
I2C_device.write_bytes(0x07, 0x00)
if pll_frequency == '160MHz':
print("Set PLL to 160 MHz mode")
......@@ -148,11 +148,10 @@ def setup_pll(pll_frequency='200MHz') :
def power(state):
ADDRESS_IO = 0x20
I2C_IO_device_A = I2C(ADDRESS_IO, BUSNR=I2CBUSNR)
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(ADDRESS_IO, BUSNR=I2CBUSNR)
I2C_IO_device_B = I2C(0x21, BUSNR=I2CBUSNR)
I2C_IO_device_B.write_bytes(0x06, 0x2C) # '0' is output
if state:
bits_to_set_A1 = 0x02 | (1 << CS) | (0 << SCLK) | (0 << SDI)
......@@ -162,9 +161,12 @@ def power(state):
bits_to_set_A1 = 0x00 | (1 << CS) | (0 << SCLK) | (0 << SDI)
bits_to_set_A2 = 0x00
bits_to_set_B1 = 0x00 | (1 << CS) | (0 << SCLK) | (0 << SDI)
I2C_IO_device_A.write_bytes(0x03, bits_to_set_A1)
if DEBUG :
stri = "Bits to reg 0 0x{0:x}".format(bits_to_set_A1)
print(stri)
I2C_IO_device_A.write_bytes(0x02, bits_to_set_A1)
I2C_IO_device_A.write_bytes(0x03, bits_to_set_A2)
I2C_IO_device_A.write_bytes(0x03, bits_to_set_B1)
I2C_IO_device_B.write_bytes(0x02, bits_to_set_B1)
def write_eeprom( data=0x01):
#
......@@ -206,20 +208,12 @@ if CHECK_EEPROM :
if PWR_RST :
power(False)
sleep(1)
sleep(5)
power(True)
if SET_PLL :
setup_pll(CLK_FREQ)
if INT_POWER_CYCLE :
print("Power OFF")
Write_byte_PLL(0x03, 0x88) # Device down
sleep(1)
print("Power ON")
Write_byte_PLL(0x03, 0x08) # Device up
print("Done")
if READ_LOCK:
if CLK_FREQ == '160MHz' :
pll_addr = PLL_160M
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment