Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Gateware
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
12
Issues
12
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Gateware
Commits
ad61f748
Commit
ad61f748
authored
May 02, 2012
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rt/dev/softpll_ng: adjusted gains, longer delock thresholds
parent
f81eb379
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
21 deletions
+60
-21
softpll_ng.c
rt/dev/softpll_ng.c
+45
-11
softpll_ng.h
rt/dev/softpll_ng.h
+2
-1
spll_helper.h
rt/dev/spll_helper.h
+6
-4
spll_main.h
rt/dev/spll_main.h
+7
-5
No files found.
rt/dev/softpll_ng.c
View file @
ad61f748
...
...
@@ -44,6 +44,7 @@ struct softpll_state {
int
helper_locked
;
int
dac_timeout
;
int
default_dac_main
;
int
delock_count
;
struct
spll_helper_state
helper
;
struct
spll_external_state
ext
;
struct
spll_main_state
mpll
;
...
...
@@ -53,6 +54,7 @@ struct softpll_state {
static
volatile
struct
softpll_state
softpll
;
static
volatile
int
ptracker_mask
=
0
;
/* fixme: should be done by spll_init() but spll_init is called to switch modes (and we won't like messing around with ptrackers there) */
void
_irq_entry
()
{
...
...
@@ -61,7 +63,7 @@ void _irq_entry()
struct
softpll_state
*
s
=
(
struct
softpll_state
*
)
&
softpll
;
/* check if there are more tags in the FIFO */
if
(
!
(
SPLL
->
CSR
&
SPLL_TRR_CSR_EMPTY
))
while
(
!
(
SPLL
->
TRR_
CSR
&
SPLL_TRR_CSR_EMPTY
))
{
trr
=
SPLL
->
TRR_R0
;
src
=
SPLL_TRR_R0_CHAN_ID_R
(
trr
);
...
...
@@ -111,8 +113,9 @@ void _irq_entry()
if
(
softpll
.
mode
==
SPLL_MODE_SLAVE
)
softpll
.
seq_state
=
SEQ_START_MAIN
;
else
{
for
(
i
=
0
;
i
<
n_chan_ref
/
2
;
i
++
)
ptracker_start
((
struct
spll_ptracker_state
*
)
&
s
->
ptrackers
[
i
]);
for
(
i
=
0
;
i
<
n_chan_ref
;
i
++
)
if
(
ptracker_mask
&
(
1
<<
i
))
ptracker_start
((
struct
spll_ptracker_state
*
)
&
s
->
ptrackers
[
i
]);
softpll
.
seq_state
=
SEQ_READY
;
}
}
...
...
@@ -128,8 +131,9 @@ void _irq_entry()
{
softpll
.
seq_state
=
SEQ_READY
;
for
(
i
=
0
;
i
<
n_chan_ref
/
2
;
i
++
)
ptracker_start
((
struct
spll_ptracker_state
*
)
&
s
->
ptrackers
[
i
]);
for
(
i
=
0
;
i
<
n_chan_ref
;
i
++
)
if
(
ptracker_mask
&
(
1
<<
i
))
ptracker_start
((
struct
spll_ptracker_state
*
)
&
s
->
ptrackers
[
i
]);
}
break
;
...
...
@@ -139,15 +143,18 @@ void _irq_entry()
// SPLL->OCER = 0;
// SPLL->RCER = 0;
softpll
.
seq_state
=
SEQ_CLEAR_DACS
;
softpll
.
delock_count
++
;
}
else
if
(
softpll
.
mode
==
SPLL_MODE_GRAND_MASTER
&&
!
external_locked
((
struct
spll_external_state
*
)
&
s
->
ext
))
{
// SPLL->OCER = 0;
// SPLL->RCER = 0;
// SPLL->ECCR = 0;
softpll
.
seq_state
=
SEQ_START_EXT
;
softpll
.
delock_count
++
;
}
else
if
(
softpll
.
mode
==
SPLL_MODE_SLAVE
&&
!
softpll
.
mpll
.
ld
.
locked
)
{
softpll
.
seq_state
=
SEQ_CLEAR_DACS
;
softpll
.
delock_count
++
;
};
break
;
};
...
...
@@ -174,8 +181,9 @@ void _irq_entry()
if
(
softpll
.
mode
==
SPLL_MODE_SLAVE
)
mpll_update
((
struct
spll_main_state
*
)
&
s
->
mpll
,
tag
,
src
);
for
(
i
=
0
;
i
<
n_chan_ref
/
2
;
i
++
)
ptracker_update
((
struct
spll_ptracker_state
*
)
&
s
->
ptrackers
[
i
],
tag
,
src
);
for
(
i
=
0
;
i
<
n_chan_ref
;
i
++
)
if
(
ptracker_mask
&
(
1
<<
i
))
ptracker_update
((
struct
spll_ptracker_state
*
)
&
s
->
ptrackers
[
i
],
tag
,
src
);
break
;
...
...
@@ -210,6 +218,7 @@ void spll_init(int mode, int slave_ref_channel, int align_pps)
softpll
.
helper_locked
=
0
;
softpll
.
mode
=
mode
;
softpll
.
default_dac_main
=
0
;
softpll
.
delock_count
=
0
;
SPLL
->
DAC_HPLL
=
0
;
SPLL
->
DAC_MAIN
=
0
;
...
...
@@ -290,7 +299,8 @@ void spll_init(int mode, int slave_ref_channel, int align_pps)
SPLL
->
EIC_IER
=
1
;
_irq_entry
();
SPLL
->
OCER
=
1
;
// _irq_entry();
enable_irq
();
...
...
@@ -364,7 +374,7 @@ void spll_get_phase_shift(int channel, int32_t *current, int32_t *target)
if
(
target
)
*
target
=
to_picos
(
st
->
phase_shift_target
);
}
int
spll_read_ptracker
(
int
channel
,
int32_t
*
phase_ps
)
int
spll_read_ptracker
(
int
channel
,
int32_t
*
phase_ps
,
int
*
enabled
)
{
volatile
struct
spll_ptracker_state
*
st
=
&
softpll
.
ptrackers
[
channel
];
int
phase
=
st
->
phase_val
;
...
...
@@ -372,6 +382,8 @@ int spll_read_ptracker(int channel, int32_t *phase_ps)
else
if
(
phase
>=
(
1
<<
HPLL_N
))
phase
-=
(
1
<<
HPLL_N
);
*
phase_ps
=
to_picos
(
phase
);
if
(
enabled
)
*
enabled
=
ptracker_mask
&
(
1
<<
st
->
id_b
)
?
1
:
0
;
return
st
->
ready
;
}
...
...
@@ -384,10 +396,10 @@ void spll_get_num_channels(int *n_ref, int *n_out)
void
spll_show_stats
()
{
if
(
softpll
.
mode
>
0
)
TRACE
(
"Irq_count %d Sequencer_state %d mode %d Alignment_state %d HL%d EL%d ML%d HY=%d MY=%d
\n
"
,
TRACE
(
"Irq_count %d Sequencer_state %d mode %d Alignment_state %d HL%d EL%d ML%d HY=%d MY=%d
DelCnt=%d
\n
"
,
irq_count
,
softpll
.
seq_state
,
softpll
.
mode
,
softpll
.
ext
.
realign_state
,
softpll
.
helper
.
ld
.
locked
,
softpll
.
ext
.
ld
.
locked
,
softpll
.
mpll
.
ld
.
locked
,
softpll
.
helper
.
pi
.
y
,
softpll
.
mpll
.
pi
.
y
);
softpll
.
helper
.
pi
.
y
,
softpll
.
mpll
.
pi
.
y
,
softpll
.
delock_count
);
}
...
...
@@ -397,4 +409,26 @@ int spll_shifter_busy(int channel)
return
mpll_shifter_busy
(
&
softpll
.
mpll
);
else
return
mpll_shifter_busy
(
&
softpll
.
aux
[
channel
-
1
]);
}
void
spll_enable_ptracker
(
int
ref_channel
,
int
enable
)
{
if
(
enable
)
{
spll_enable_tagger
(
ref_channel
,
1
);
ptracker_start
((
struct
spll_ptracker_state
*
)
&
softpll
.
ptrackers
[
ref_channel
]);
ptracker_mask
|=
(
1
<<
ref_channel
);
TRACE
(
"Enabling ptracker channel: %d
\n
"
,
ref_channel
);
}
else
{
ptracker_mask
&=
~
(
1
<<
ref_channel
);
if
(
ref_channel
!=
softpll
.
mpll
.
id_ref
)
spll_enable_tagger
(
ref_channel
,
0
);
TRACE
(
"Disabling ptracker tagger: %d
\n
"
,
ref_channel
);
}
}
int
spll_get_delock_count
()
{
return
softpll
.
delock_count
;
}
\ No newline at end of file
rt/dev/softpll_ng.h
View file @
ad61f748
...
...
@@ -18,9 +18,10 @@ void spll_stop_channel(int channel);
int
spll_check_lock
(
int
channel
);
void
spll_set_phase_shift
(
int
channel
,
int32_t
value_picoseconds
);
void
spll_get_phase_shift
(
int
channel
,
int32_t
*
current
,
int32_t
*
target
);
int
spll_read_ptracker
(
int
channel
,
int32_t
*
phase_ps
);
int
spll_read_ptracker
(
int
channel
,
int32_t
*
phase_ps
,
int
*
enabled
);
void
spll_get_num_channels
(
int
*
n_ref
,
int
*
n_out
);
int
spll_shifter_busy
(
int
channel
);
int
spll_get_delock_count
();
#endif
rt/dev/spll_helper.h
View file @
ad61f748
...
...
@@ -17,6 +17,7 @@ struct spll_helper_state {
int
p_setpoint
,
tag_d0
;
int
ref_src
;
int
sample_n
;
int
delock_count
;
spll_pi_t
pi
;
spll_lock_det_t
ld
;
};
...
...
@@ -27,16 +28,17 @@ static void helper_init(struct spll_helper_state *s, int ref_channel)
/* Phase branch PI controller */
s
->
pi
.
y_min
=
5
;
s
->
pi
.
y_max
=
(
1
<<
DAC_BITS
)
-
5
;
s
->
pi
.
kp
=
(
int
)(
0
.
3
*
32
.
0
*
16
.
0
);
s
->
pi
.
ki
=
(
int
)(
0
.
03
*
32
.
0
*
3
.
0
);
s
->
pi
.
kp
=
(
int
)(
0
.
3
*
32
.
0
*
16
.
0
);
// / 2;
s
->
pi
.
ki
=
(
int
)(
0
.
03
*
32
.
0
*
3
.
0
);
// / 2;
s
->
pi
.
anti_windup
=
1
;
/* Phase branch lock detection */
s
->
ld
.
threshold
=
200
;
s
->
ld
.
lock_samples
=
1000
;
s
->
ld
.
delock_samples
=
9
00
;
s
->
ld
.
lock_samples
=
1000
0
;
s
->
ld
.
delock_samples
=
1
00
;
s
->
ref_src
=
ref_channel
;
s
->
delock_count
=
0
;
}
static
int
helper_update
(
struct
spll_helper_state
*
s
,
int
tag
,
int
source
)
...
...
rt/dev/spll_main.h
View file @
ad61f748
...
...
@@ -25,6 +25,7 @@ struct spll_main_state {
int
phase_shift_current
;
int
id_ref
,
id_out
;
/* IDs of the reference and the output channel */
int
sample_n
;
int
delock_count
;
};
...
...
@@ -35,13 +36,14 @@ static void mpll_init(struct spll_main_state *s, int id_ref, int id_out)
s
->
pi
.
y_max
=
65530
;
s
->
pi
.
anti_windup
=
1
;
s
->
pi
.
bias
=
65000
;
s
->
pi
.
kp
=
1100
;
s
->
pi
.
ki
=
30
;
s
->
pi
.
kp
=
1100
;
// / 2;
s
->
pi
.
ki
=
30
;
// / 2;
s
->
delock_count
=
0
;
/* Freqency branch lock detection */
s
->
ld
.
threshold
=
120
;
s
->
ld
.
lock_samples
=
4
00
;
s
->
ld
.
delock_samples
=
39
0
;
s
->
ld
.
threshold
=
120
0
;
s
->
ld
.
lock_samples
=
10
00
;
s
->
ld
.
delock_samples
=
10
0
;
s
->
id_ref
=
id_ref
;
s
->
id_out
=
id_out
;
...
...
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