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
29
Issues
29
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
263b982d
Commit
263b982d
authored
Mar 19, 2012
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
softpll: tom's patches
parent
4a319b43
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
31 deletions
+77
-31
softpll_ng.c
dev/softpll_ng.c
+73
-26
spll_helper.h
include/spll_helper.h
+4
-5
No files found.
dev/softpll_ng.c
View file @
263b982d
...
...
@@ -56,13 +56,6 @@ void spll_init()
n_chan_out
=
SPLL_CSR_N_OUT_R
(
SPLL
->
CSR
);
TRACE_DEV
(
"SPLL_Init: %d ref channels, %d out channels
\n
"
,
n_chan_ref
,
n_chan_out
);
SPLL
->
DAC_HPLL
=
0
;
TRACE_DEV
(
"delay on
\n
"
);
timer_delay
(
1000
);
//GD timer_delay(100000);
//GD
timer_delay
(
1000
);
TRACE_DEV
(
"delay off
\n
"
);
SPLL
->
CSR
=
0
;
SPLL
->
OCER
=
0
;
...
...
@@ -70,6 +63,7 @@ void spll_init()
SPLL
->
RCGER
=
0
;
SPLL
->
DCCR
=
0
;
SPLL
->
DEGLITCH_THR
=
1000
;
SPLL
->
DAC_MAIN
=
32000
;
while
(
!
(
SPLL
->
TRR_CSR
&
SPLL_TRR_CSR_EMPTY
))
dummy
=
SPLL
->
TRR_R0
;
dummy
=
SPLL
->
PER_HPLL
;
SPLL
->
EIC_IER
=
1
;
...
...
@@ -80,7 +74,8 @@ int spll_check_lock()
return
helper
.
ld
.
locked
?
1
:
0
;
}
#define CHAN_TCXO 8
#define CHAN_RX 0
#define CHAN_TCXO 1
void
spll_test
()
{
...
...
@@ -88,32 +83,84 @@ void spll_test()
volatile
int
dummy
;
TRACE_DEV
(
"running spll_init
\n
"
);
spll_init
();
helper_init
(
&
helper
,
0
);
TRACE_DEV
(
"spll_init
\n
"
);
helper_start
(
&
helper
);
TRACE_DEV
(
"helper start
\n
"
);
mpll_init
(
&
mpll
,
0
,
0
);
//CHAN_TCXO);
enable_irq
();
TRACE_DEV
(
"enable irq
\n
"
);
// TRACE_DEV("enable irq\n");
// mpll_init(&mpll, 0, CHAN_TCXO);
while
(
!
helper
.
ld
.
locked
)
;
//TRACE("%d\n", helper.phase.ld.locked);
TRACE_DEV
(
"Helper locked, starting main
\n
"
);
mpll_start
(
&
mpll
);
//
mpll_start(&mpll);
}
/*
#define CHAN_AUX 7
#define CHAN_EXT 6
static
int
spll_master
=
0
;
void
softpll_set_mode
(
int
master
)
{
spll_master
=
master
;
}
/* Enables SoftPLL in Slave mode.*/
void
softpll_enable
()
{
if
(
spll_master
)
mprintf
(
"Softpll: running in MASTER mode
\n
"
);
else
mprintf
(
"Softpll: running in SLAVE mode
\n
"
);
spll_init
();
helper_init
(
&
helper
,
spll_master
?
CHAN_TCXO
:
CHAN_RX
);
/* Change CHAN_RX to CHAN_TCXO if master mode */
helper_start
(
&
helper
);
enable_irq
();
while
(
!
helper
.
ld
.
locked
)
timer_delay
(
1
);
TRACE_DEV
(
"Helper locked
\n
"
);
if
(
spll_master
)
return
;
/* comment the lines below if Master mode */
mpll_init
(
&
mpll
,
CHAN_RX
,
CHAN_TCXO
);
mpll_start
(
&
mpll
);
while
(
!
mpll
.
ld
.
locked
)
timer_delay
(
1
);
TRACE_DEV
(
"Softpll locked
\n
"
);
}
int
softpll_check_lock
()
{
static
int
prev_lck
=
0
;
int
lck
=
mpll
.
ld
.
locked
&&
helper
.
ld
.
locked
;
if
(
lck
&&
!
prev_lck
)
{
TRACE_DEV
(
"[softpll]: got lock
\n
"
);
}
else
if
(
!
lck
&&
prev_lck
)
TRACE_DEV
(
"[softpll]: lost lock
\n
"
);
prev_lck
=
lck
;
return
lck
;
}
int
softpll_get_aux_status
()
{
return
0
;
}
int
softpll_busy
(
int
channel
)
{
return
mpll
.
phase_shift_target
!=
mpll
.
phase_shift_current
;
}
int spll_gm_measure_ext_phase(
)
void
softpll_set_phase
(
int
ps
)
{
SPLL->CSR = 0;
SPLL->DCCR = SPLL_DCCR_GATE_DIV_W(25);
SPLL->RCGER = (1<<CHAN_AUX);
SPLL->RCGER = (1<<CHAN_EXT);
mpll
.
phase_shift_target
=
((
int32_t
)
((
int64_t
)
ps
*
(
long
long
)(
1
<<
HPLL_N
)
/
8000LL
));
}
*/
void
softpll_disable
()
{
disable_irq
();
}
int
softpll_get_setpoint
()
{
return
mpll
.
phase_shift_target
;
}
include/spll_helper.h
View file @
263b982d
...
...
@@ -20,7 +20,7 @@ struct spll_helper_state {
spll_pi_t
pi
;
spll_lock_det_t
ld
;
};
static
void
helper_init
(
struct
spll_helper_state
*
s
,
int
ref_channel
)
{
...
...
@@ -72,7 +72,6 @@ static int helper_update(struct spll_helper_state *s, int tag, int source)
err
=
(
tag
+
s
->
p_adder
)
-
s
->
p_setpoint
;
// if(s->tag_d0 - tag > -100000)
TRACE_DEV
(
"%d
\n
"
,
s
->
tag_d0
-
tag
);
//spll_debug(DBG_ERR | DBG_HELPER, s->tag_d0-tag, 1);
if
(
HELPER_ERROR_CLAMP
)
...
...
@@ -96,9 +95,9 @@ static int helper_update(struct spll_helper_state *s, int tag, int source)
y
=
pi_update
(
&
s
->
pi
,
err
);
SPLL
->
DAC_HPLL
=
y
;
//
spll_debug(DBG_SAMPLE_ID | DBG_HELPER, s->sample_n++, 0);
//
spll_debug(DBG_Y | DBG_HELPER, y, 0);
//
spll_debug(DBG_ERR | DBG_HELPER, err, 1);
spll_debug
(
DBG_SAMPLE_ID
|
DBG_HELPER
,
s
->
sample_n
++
,
0
);
spll_debug
(
DBG_Y
|
DBG_HELPER
,
y
,
0
);
spll_debug
(
DBG_ERR
|
DBG_HELPER
,
err
,
1
);
if
(
ld_update
(
&
s
->
ld
,
err
))
return
SPLL_LOCKED
;
...
...
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