Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Schedules
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
Software for White Rabbit PTP Core
Commits
e52af7f5
Commit
e52af7f5
authored
Aug 05, 2014
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VCO characterization command, fix code duplication
parent
6ffd84cd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
88 deletions
+43
-88
cmd_pll.c
shell/cmd_pll.c
+0
-43
softpll_ng.c
softpll/softpll_ng.c
+42
-1
softpll_ng.h
softpll/softpll_ng.h
+1
-1
wrs_main.c
wrs_main.c
+0
-43
No files found.
shell/cmd_pll.c
View file @
e52af7f5
...
...
@@ -14,49 +14,6 @@
#include "softpll_ng.h"
#include "shell.h"
static
int
calc_apr
(
int
meas_min
,
int
meas_max
,
int
f_center
)
{
// apr_min is in PPM
int64_t
delta_low
=
meas_min
-
f_center
;
int64_t
delta_hi
=
meas_max
-
f_center
;
if
(
delta_low
>=
0
)
return
-
1
;
if
(
delta_hi
<=
0
)
return
-
1
;
int
ppm_lo
=
-
(
int64_t
)
delta_low
*
1000000LL
/
f_center
;
int
ppm_hi
=
(
int64_t
)
delta_hi
*
1000000LL
/
f_center
;
return
ppm_lo
<
ppm_hi
?
ppm_lo
:
ppm_hi
;
}
extern
void
disable_irq
();
static
void
check_vco_frequencies
()
{
disable_irq
();
int
f_min
,
f_max
;
pp_printf
(
"SoftPLL VCO Frequency/APR test:
\n
"
);
spll_set_dac
(
-
1
,
0
);
f_min
=
spll_measure_frequency
(
SPLL_OSC_DMTD
);
spll_set_dac
(
-
1
,
65535
);
f_max
=
spll_measure_frequency
(
SPLL_OSC_DMTD
);
pp_printf
(
"DMTD VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.
\n
"
,
f_min
,
f_max
,
calc_apr
(
f_min
,
f_max
,
62500000
));
spll_set_dac
(
0
,
0
);
f_min
=
spll_measure_frequency
(
SPLL_OSC_REF
);
spll_set_dac
(
0
,
65535
);
f_max
=
spll_measure_frequency
(
SPLL_OSC_REF
);
pp_printf
(
"REF VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.
\n
"
,
f_min
,
f_max
,
calc_apr
(
f_min
,
f_max
,
125000000
));
f_min
=
spll_measure_frequency
(
SPLL_OSC_EXT
);
pp_printf
(
"EXT clock: Freq=%d Hz
\n
"
,
f_min
);
}
static
int
cmd_pll
(
const
char
*
args
[])
{
int
cur
,
tgt
;
...
...
softpll/softpll_ng.c
View file @
e52af7f5
...
...
@@ -644,7 +644,7 @@ void spll_update()
spll_update_aux_clocks
();
}
int
spll_measure_frequency
(
int
osc
)
static
int
spll_measure_frequency
(
int
osc
)
{
volatile
uint32_t
*
reg
;
...
...
@@ -663,3 +663,44 @@ int spll_measure_frequency(int osc)
timer_delay_ms
(
2000
);
return
(
*
reg
)
&
(
0xfffffff
);
}
static
int
calc_apr
(
int
meas_min
,
int
meas_max
,
int
f_center
)
{
// apr_min is in PPM
int64_t
delta_low
=
meas_min
-
f_center
;
int64_t
delta_hi
=
meas_max
-
f_center
;
if
(
delta_low
>=
0
)
return
-
1
;
if
(
delta_hi
<=
0
)
return
-
1
;
int
ppm_lo
=
-
(
int64_t
)
delta_low
*
1000000LL
/
f_center
;
int
ppm_hi
=
(
int64_t
)
delta_hi
*
1000000LL
/
f_center
;
return
ppm_lo
<
ppm_hi
?
ppm_lo
:
ppm_hi
;
}
void
check_vco_frequencies
()
{
disable_irq
();
int
f_min
,
f_max
;
TRACE_DEV
(
"SoftPLL VCO Frequency/APR test:
\n
"
);
spll_set_dac
(
-
1
,
0
);
f_min
=
spll_measure_frequency
(
SPLL_OSC_DMTD
);
spll_set_dac
(
-
1
,
65535
);
f_max
=
spll_measure_frequency
(
SPLL_OSC_DMTD
);
TRACE_DEV
(
"DMTD VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.
\n
"
,
f_min
,
f_max
,
calc_apr
(
f_min
,
f_max
,
62500000
));
spll_set_dac
(
0
,
0
);
f_min
=
spll_measure_frequency
(
SPLL_OSC_REF
);
spll_set_dac
(
0
,
65535
);
f_max
=
spll_measure_frequency
(
SPLL_OSC_REF
);
TRACE_DEV
(
"REF VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.
\n
"
,
f_min
,
f_max
,
calc_apr
(
f_min
,
f_max
,
REF_CLOCK_FREQ_HZ
));
f_min
=
spll_measure_frequency
(
SPLL_OSC_EXT
);
TRACE_DEV
(
"EXT clock: Freq=%d Hz
\n
"
,
f_min
);
}
softpll/softpll_ng.h
View file @
e52af7f5
...
...
@@ -127,7 +127,7 @@ void spll_set_dac(int out_channel, int value);
/* Returns current DAC sample value for output (out_channel) */
int
spll_get_dac
(
int
out_channel
);
int
spll_measure_frequency
(
int
osc
);
void
check_vco_frequencies
(
);
#endif // __SOFTPLL_NG_H
wrs_main.c
View file @
e52af7f5
...
...
@@ -8,49 +8,6 @@
const
char
*
build_revision
;
const
char
*
build_date
;
static
int
calc_apr
(
int
meas_min
,
int
meas_max
,
int
f_center
)
{
// apr_min is in PPM
int64_t
delta_low
=
meas_min
-
f_center
;
int64_t
delta_hi
=
meas_max
-
f_center
;
if
(
delta_low
>=
0
)
return
-
1
;
if
(
delta_hi
<=
0
)
return
-
1
;
int
ppm_lo
=
-
(
int64_t
)
delta_low
*
1000000LL
/
f_center
;
int
ppm_hi
=
(
int64_t
)
delta_hi
*
1000000LL
/
f_center
;
return
ppm_lo
<
ppm_hi
?
ppm_lo
:
ppm_hi
;
}
extern
void
disable_irq
();
static
void
check_vco_frequencies
()
{
disable_irq
();
int
f_min
,
f_max
;
TRACE
(
"SoftPLL VCO Frequency/APR test:
\n
"
);
spll_set_dac
(
-
1
,
0
);
f_min
=
spll_measure_frequency
(
SPLL_OSC_DMTD
);
spll_set_dac
(
-
1
,
65535
);
f_max
=
spll_measure_frequency
(
SPLL_OSC_DMTD
);
TRACE
(
"DMTD VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.
\n
"
,
f_min
,
f_max
,
calc_apr
(
f_min
,
f_max
,
62500000
));
spll_set_dac
(
0
,
0
);
f_min
=
spll_measure_frequency
(
SPLL_OSC_REF
);
spll_set_dac
(
0
,
65535
);
f_max
=
spll_measure_frequency
(
SPLL_OSC_REF
);
TRACE
(
"REF VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.
\n
"
,
f_min
,
f_max
,
calc_apr
(
f_min
,
f_max
,
62500000
));
f_min
=
spll_measure_frequency
(
SPLL_OSC_EXT
);
TRACE
(
"EXT clock: Freq=%d Hz
\n
"
,
f_min
);
}
int
main
(
void
)
{
uint32_t
start_tics
=
timer_get_tics
();
...
...
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