Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python_test_scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
python_test_scripts
Commits
cdb892dd
Commit
cdb892dd
authored
Aug 20, 2021
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Update APSCT_CLK, both pll's are locking
parent
74ea62d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
APSCT_CLK_I2C.py
+37
-17
37 additions, 17 deletions
APSCT_CLK_I2C.py
with
37 additions
and
17 deletions
APSCT_CLK_I2C.py
+
37
−
17
View file @
cdb892dd
...
...
@@ -23,7 +23,7 @@ if os.name =="posix":
else
:
from
I2C_serial
import
*
DEBUG
=
Tru
e
DEBUG
=
Fals
e
I2CBUSNR
=
3
sleep_time
=
0.05
PWR_RST
=
False
...
...
@@ -34,7 +34,7 @@ RESET_PLL = False
UPDATE_PLL
=
False
READ_ALL
=
False
CHECK_EEPROM
=
True
CLK_FREQ
=
'
200MHz
'
dev_i2c_eeprom
=
I2C
(
0x50
)
dev_i2c_eeprom
.
bus_nr
=
I2CBUSNR
...
...
@@ -55,8 +55,11 @@ def Write_byte_PLL(reg_address, wr_data, ADDRESS=0x20):
stri
=
"
Write : 0x{0:{fill}2x} to Address : 0x{1:{fill}2x}
"
.
format
(
wr_data
,
reg_address
,
fill
=
'
0
'
)
print
(
stri
)
I2C_device
.
write_bytes
(
0x06
,
0x2C
)
if
DEBUG
:
rd_bytes
=
I2C_device
.
read_bytes
(
0x06
,
1
)
stri
=
"
IO expander wrote 0x{0:x}, read 0x{1}
"
.
format
(
0x2C
,
rd_bytes
[
1
])
print
(
stri
)
data
=
(
reg_address
<<
9
)
+
(
PLL_rw
<<
8
)
+
wr_data
bit_array
=
"
{0:{fill}16b}
"
.
format
(
data
,
fill
=
'
0
'
)
I2C_device
.
write_bytes
(
0x02
,
0x02
|
(
0x1
<<
CS
))
for
bit
in
bit_array
:
...
...
@@ -73,9 +76,9 @@ def Write_byte_PLL(reg_address, wr_data, ADDRESS=0x20):
Write_data
=
0x02
|
(
1
<<
CS
)
|
(
0
<<
SCLK
)
|
(
0
<<
SDI
)
I2C_device
.
write_bytes
(
0x02
,
Write_data
)
if
DEBUG
:
read_bits
=
Read_byte_PLL
(
reg_address
,
ADDRESS
)
stri
=
"
Bits written
{
0} to register
{1
} read from PLL are {2}
"
.
format
(
wr_data
,
reg_address
,
read_bits
)
print
(
stri
)
read_bits
=
Read_byte_PLL
(
reg_address
,
nof_bytes
=
1
,
ADDRESS
=
ADDRESS
)
#
stri = "Bits written 0
x{0:x
} to register
0x{1:x
} read from PLL are {2}".format(wr_data, reg_address, read_bits)
#
print(stri)
def
Read_byte_PLL
(
reg_address
,
nof_bytes
=
1
,
ADDRESS
=
0x20
):
...
...
@@ -118,22 +121,23 @@ def Read_byte_PLL(reg_address, nof_bytes=1, ADDRESS=0x20 ):
def
setup_pll
(
pll_frequency
=
'
200MHz
'
)
:
# Check PLL is in lock
if
pll_frequency
==
'
160MHz
'
:
pll_address
=
PLL_160M
I2C_device
=
I2C
(
0x20
,
BUSNR
=
I2CBUSNR
)
I2C_device
.
write_bytes
(
0x07
,
0x00
)
I2C_device
.
write_bytes
(
0x07
,
0x08
)
if
pll_frequency
==
'
160MHz
'
:
pll_address
=
PLL_160M
I2C_device
.
write_bytes
(
0x03
,
0x08
)
else
:
pll_address
=
PLL_200M
I2C_device
=
I2C
(
0x20
,
BUSNR
=
I2CBUSNR
)
I2C_device
.
write_bytes
(
0x07
,
0x00
)
I2C_device
.
write_bytes
(
0x07
,
0xF8
)
I2C_device
.
write_bytes
(
0x03
,
0xF8
)
Write_byte_PLL
(
0x05
,
0x97
,
pll_address
)
Write_byte_PLL
(
0x06
,
0x10
,
pll_address
)
# cp inv = 0xF4 other 0xE4
Write_byte_PLL
(
0x07
,
0x04
,
pll_address
)
# Divider R = 1 dec
Write_byte_PLL
(
0x08
,
0x01
,
pll_address
)
Write_byte_PLL
(
0x07
,
0x00
,
pll_address
)
Write_byte_PLL
(
0x09
,
0x10
,
pll_address
)
# reset
if
pll_frequency
==
'
160MHz
'
:
Write_byte_PLL
(
0x0A
,
0x10
,
pll_address
)
else
:
Write_byte_PLL
(
0x0A
,
0x14
,
pll_address
)
Write_byte_PLL
(
0x09
,
0x00
,
pll_address
)
Write_byte_PLL
(
0x0D
,
0x01
,
pll_address
)
# Dig CLK = 200/1 = 200 MHz
...
...
@@ -153,6 +157,18 @@ def power(state):
bits_to_set
=
0x40
I2C_IO_device
.
write_bytes
(
0x02
,
bits_to_set
)
def
write_eeprom
(
data
=
0x01
):
#
# Write the EEPROM with the serial number etc.
#
ret_ack
,
ret_value
=
dev_i2c_eeprom
.
read_bytes
(
0
)
if
ret_ack
<
1
:
print
(
"
EEPROM not found during write
"
)
return
False
else
:
dev_i2c_eeprom
.
write_bytes
(
0x00
,
data
)
sleep
(
0.1
)
return
True
def
read_eeprom
():
#
...
...
@@ -171,7 +187,7 @@ def wr_rd_eeprom( value=0x34):
# Write and Read the EEPROM to check functionality
#
if
write_eeprom
(
value
):
ret_value
=
self
.
read_eeprom
()
ret_value
=
read_eeprom
()
stri
=
"
Wrote to EEPROM: 0x{0:X}, Read from EEPROM: 0x{1}
"
.
format
(
value
,
ret_value
)
print
(
stri
)
return
True
...
...
@@ -185,7 +201,7 @@ if PWR_RST :
power
(
True
)
if
SET_PLL
:
setup_pll
()
setup_pll
(
CLK_FREQ
)
if
INT_POWER_CYCLE
:
print
(
"
Power OFF
"
)
...
...
@@ -206,7 +222,11 @@ if RESET_PLL :
if
READ_LOCK
:
ret_value
=
Read_byte_PLL
(
0x00
,
nof_bytes
=
1
)
if
CLK_FREQ
==
'
160MHz
'
:
pll_addr
=
PLL_160M
else
:
pll_addr
=
PLL_200M
ret_value
=
Read_byte_PLL
(
0x00
,
nof_bytes
=
1
,
ADDRESS
=
pll_addr
)
status_pll
=
int
(
ret_value
,
2
)
if
status_pll
==
0x04
:
print
(
"
PLL in lock
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment