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
74ea62d1
Commit
74ea62d1
authored
Aug 20, 2021
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Added EEPROM check + read from PLL after write to check write.
parent
bf6c2e04
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
+41
-0
41 additions, 0 deletions
APSCT_CLK_I2C.py
with
41 additions
and
0 deletions
APSCT_CLK_I2C.py
+
41
−
0
View file @
74ea62d1
...
...
@@ -23,6 +23,7 @@ if os.name =="posix":
else
:
from
I2C_serial
import
*
DEBUG
=
True
I2CBUSNR
=
3
sleep_time
=
0.05
PWR_RST
=
False
...
...
@@ -32,6 +33,10 @@ INT_POWER_CYCLE = False
RESET_PLL
=
False
UPDATE_PLL
=
False
READ_ALL
=
False
CHECK_EEPROM
=
True
dev_i2c_eeprom
=
I2C
(
0x50
)
dev_i2c_eeprom
.
bus_nr
=
I2CBUSNR
CS
=
6
SCLK
=
4
...
...
@@ -67,6 +72,11 @@ 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
)
def
Read_byte_PLL
(
reg_address
,
nof_bytes
=
1
,
ADDRESS
=
0x20
):
#
...
...
@@ -110,8 +120,14 @@ 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
)
else
:
pll_address
=
PLL_200M
I2C_device
=
I2C
(
0x20
,
BUSNR
=
I2CBUSNR
)
I2C_device
.
write_bytes
(
0x07
,
0x00
)
I2C_device
.
write_bytes
(
0x07
,
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
...
...
@@ -138,6 +154,31 @@ def power(state):
I2C_IO_device
.
write_bytes
(
0x02
,
bits_to_set
)
def
read_eeprom
():
#
# Read the EEPROM with the serial number etc.
#
ret_ack
,
ret_value
=
dev_i2c_eeprom
.
read_last_reg
(
1
)
if
ret_ack
<
1
:
print
(
"
no EEPROM found during read
"
)
return
False
else
:
ret_ack
,
ret_value
=
dev_i2c_eeprom
.
read_bytes
(
0x00
,
1
)
return
ret_value
def
wr_rd_eeprom
(
value
=
0x34
):
#
# Write and Read the EEPROM to check functionality
#
if
write_eeprom
(
value
):
ret_value
=
self
.
read_eeprom
()
stri
=
"
Wrote to EEPROM: 0x{0:X}, Read from EEPROM: 0x{1}
"
.
format
(
value
,
ret_value
)
print
(
stri
)
return
True
if
CHECK_EEPROM
:
wr_rd_eeprom
()
if
PWR_RST
:
power
(
False
)
sleep
(
1
)
...
...
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