Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Production Test Suite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Production Test Suite
Commits
3631e053
Commit
3631e053
authored
May 29, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test04: Uses common modules, added exception handling.
parent
95dc686a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
62 deletions
+88
-62
test04.py
test/fmcadc100m14b4cha/python/test04.py
+88
-62
No files found.
test/fmcadc100m14b4cha/python/test04.py
View file @
3631e053
...
...
@@ -4,16 +4,26 @@
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Last modifications: 29/5/2012
# Import system modules
import
sys
import
rr
import
time
import
os
# Add common modules and libraries location to path
sys
.
path
.
append
(
'../../../'
)
sys
.
path
.
append
(
'../../../gnurabbit/python/'
)
sys
.
path
.
append
(
'../../../common/'
)
# Import common modules
from
ptsexcept
import
*
import
rr
# Import specific modules
from
fmc_adc_spec
import
*
from
fmc_adc
import
*
import
fmc_adc
"""
test04: Test Si570 programmable oscillator
...
...
@@ -21,33 +31,38 @@ test04: Test Si570 programmable oscillator
Note: Requires test00.py to run first to load the firmware!
"""
SI570_ADDR
=
0x55
SI570_XTAL_FREQ_MIN
=
114.056
SI570_XTAL_FREQ_MAX
=
114.514
SI570_FOUT
=
100.000
SI570_FOUT_TOL
=
1.0
SI570_RFREQ
=
42
SI570_N1
=
7
SI570_HS_DIV
=
2
def
main
(
default_directory
=
'.'
):
"""
path_fpga_loader = '../../../gnurabbit/user/fpga_loader';
path_firmware = '../firmwares/spec_fmcadc100m14b4cha.bin';
firmware_loader = os.path.join(default_directory, path_fpga_loader)
bitstream = os.path.join(default_directory, path_firmware)
print firmware_loader + ' ' + bitstream
os.system( firmware_loader + ' ' + bitstream )
time.sleep(2);
"""
# Objects declaration
spec
=
rr
.
Gennum
()
# bind to the SPEC board
fmc
=
fmc_adc
.
CFmcAdc100Ms
(
spec
)
# Constants declaration
TEST_NB
=
4
EXPECTED_BITSTREAM_TYPE
=
0x1
SI570_ADDR
=
0x55
SI570_XTAL_FREQ_MIN
=
114.056
SI570_XTAL_FREQ_MAX
=
114.514
SI570_FOUT
=
100.000
SI570_FOUT_TOL
=
1.0
start_test_time
=
time
.
time
()
print
"================================================================================"
print
"Test
%02
d start
\n
"
%
TEST_NB
# SPEC object declaration
print
"Loading hardware access library and opening device.
\n
"
spec
=
rr
.
Gennum
()
# Carrier object declaration (SPEC board specific part)
# Used to check that the firmware is loaded.
try
:
carrier
=
CFmcAdc100mSpec
(
spec
,
EXPECTED_BITSTREAM_TYPE
)
except
FmcAdc100mSpecOperationError
as
e
:
raise
PtsCritical
(
"Carrier init failed, test stopped:
%
s"
%
e
)
# Mezzanine object declaration (FmcAdc100m14b4cha board specific part)
try
:
fmc
=
CFmcAdc100m
(
spec
)
except
FmcAdc100mOperationError
as
e
:
raise
PtsCritical
(
"Mezzanine init failed, test stopped:
%
s"
%
e
)
# Scan i2c bus
periph_addr
=
fmc
.
i2c_scan
()
...
...
@@ -55,42 +70,53 @@ def main (default_directory='.'):
# Check that the EEPROM is detected on the I2C bus
if
(
0
==
len
(
periph_addr
)):
raise
PtsError
(
'No peripheral detected on I2C bus'
)
else
:
if
(
1
!=
len
(
periph_addr
)):
raise
PtsError
(
'Signal integrity problem detected on I2C bus,
%
d devices detected instead of 1'
%
(
len
(
periph_addr
)))
if
(
1
!=
len
(
periph_addr
)):
raise
PtsError
(
'Signal integrity problem detected on I2C bus,
%
d devices detected instead of 1'
%
(
len
(
periph_addr
)))
if
(
SI570_ADDR
!=
periph_addr
[
0
]):
raise
PtsError
(
'Wrong device mounted on I2C bus, address is:0x
%.2
X expected:0x
%.2
X'
%
(
periph_addr
[
0
],
SI570_ADDR
))
try
:
# Get Si570 configuration
rfreq
,
n1
,
hs_div
=
fmc
.
get_si570_config
()
# Pritn Si570 configuration
fmc
.
print_si570_config
()
print
""
# Check that HS_DIV is different from 0
# If HS_DIV register value is "100" or "110" (not used) get_si570_config returns 0
if
(
hs_div
==
0
):
raise
PtsError
(
'Si570 invalid HS_DIV value'
)
# Calculate min and max output frequency based on the min and max xtal frequency
# See http://cp-siliconlabs.kb.net/article.aspx?article=311398&p=12972
f_out_min
=
(
SI570_XTAL_FREQ_MIN
*
rfreq
)
/
(
float
(
n1
)
*
float
(
hs_div
))
f_out_max
=
(
SI570_XTAL_FREQ_MAX
*
rfreq
)
/
(
float
(
n1
)
*
float
(
hs_div
))
print
"FOUT_MIN :
%3.3
f"
%
f_out_min
print
"FOUT_MAX :
%3.3
f"
%
f_out_max
# Check that output frequency is within the limits
f_out_limit_min
=
SI570_FOUT
-
SI570_FOUT_TOL
f_out_limit_max
=
SI570_FOUT
+
SI570_FOUT_TOL
print
"FOUT_LIMIT_MIN :
%3.3
f"
%
f_out_limit_min
print
"FOUT_LIMIT_MAX :
%3.3
f"
%
f_out_limit_max
print
"
%3.3
f <
%3.3
f <
%3.3
f <
%3.3
f <
%3.3
f ? => "
%
(
f_out_limit_min
,
f_out_min
,
SI570_FOUT
,
f_out_max
,
f_out_limit_max
),
if
(
f_out_limit_min
<
f_out_min
)
and
(
f_out_min
<
SI570_FOUT
)
and
(
SI570_FOUT
<
f_out_max
)
and
(
f_out_max
<
f_out_limit_max
):
print
"OK"
print
"Si570 frequency output is within tolerance"
else
:
if
(
SI570_ADDR
!=
periph_addr
[
0
]):
raise
PtsError
(
'Wrong device mounted on I2C bus, address is:0x
%.2
X expected:0x
%.2
X'
%
(
periph_addr
[
0
],
SI570_ADDR
))
# Get Si570 configuration
rfreq
,
n1
,
hs_div
=
fmc
.
get_si570_config
()
print
(
"
\n
Print Si570 configuration"
)
print
(
"RFREQ :
%3.28
f"
)
%
rfreq
print
(
"N1 :
%
d"
)
%
n1
print
(
"HS_DIV :
%
d"
)
%
hs_div
# Check that HS_DIV is different from 0
# If HS_DIV register value is "100" or "110" (not used) get_si570_config returns 0
if
(
hs_div
==
0
):
raise
PtsError
(
'Si570 invalid HS_DIV value'
)
# Calculate min and max output frequency based on the min and max xtal frequency
# See http://cp-siliconlabs.kb.net/article.aspx?article=311398&p=12972
f_out_min
=
(
SI570_XTAL_FREQ_MIN
*
rfreq
)
/
(
float
(
n1
)
*
float
(
hs_div
))
f_out_max
=
(
SI570_XTAL_FREQ_MAX
*
rfreq
)
/
(
float
(
n1
)
*
float
(
hs_div
))
print
(
"FOUT_MIN :
%3.3
f"
)
%
f_out_min
print
(
"FOUT_MAX :
%3.3
f"
)
%
f_out_max
# Check that output frequency is within the limits
f_out_limit_min
=
SI570_FOUT
-
SI570_FOUT_TOL
f_out_limit_max
=
SI570_FOUT
+
SI570_FOUT_TOL
print
(
"FOUT_LIMIT_MIN :
%3.3
f"
)
%
f_out_limit_min
print
(
"FOUT_LIMIT_MAX :
%3.3
f"
)
%
f_out_limit_max
if
(
f_out_limit_min
<
f_out_min
)
and
(
f_out_min
<
SI570_FOUT
)
and
(
SI570_FOUT
<
f_out_max
)
and
(
f_out_max
<
f_out_limit_max
):
print
(
"Si570 frequency output is within tolerance"
)
else
:
raise
PtsError
(
'Si570 frequency output is outside of the tolerance'
)
print
"FAILED"
raise
PtsError
(
'Si570 frequency output is outside of the tolerance'
)
except
FmcAdc100mOperationError
as
e
:
raise
PtsError
(
"Test failed:
%
s"
%
e
)
print
""
print
"==> End of test
%02
d"
%
TEST_NB
print
"================================================================================"
end_test_time
=
time
.
time
()
print
"Test
%02
d elapsed time:
%.2
f seconds
\n
"
%
(
TEST_NB
,
end_test_time
-
start_test_time
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment