Commit a2ee4ec5 authored by José López Jiménez's avatar José López Jiménez

Fixes on the HO flow operation

Prior to this commit, the holdover operation would only apply the latest "good" position of the DAC. This has been fixed by not disabling irqs altogether and findin a more "proper" way to do this. Now, the tagger is disabled in holdover mode, and we prevent the reset of the softpll caused by a link down event.
parent 72fee084
......@@ -278,6 +278,9 @@ void spll_init(int mode, int slave_ref_channel, int align_pps)
SPLL = (volatile struct SPLL_WB *)BASE_SOFTPLL;
PPSG = (volatile struct PPSG_WB *)BASE_PPS_GEN;
if(s->mpll.ld.ho_active==1)
return;
uint32_t csr = SPLL->CSR;
spll_n_chan_ref = SPLL_CSR_N_REF_R(csr);
......@@ -468,9 +471,9 @@ void spll_show_stats()
struct softpll_state *s = (struct softpll_state *)&softpll;
if (softpll.mode > 0)
pp_printf("softpll: irqs %d seq %s mode %d "
pp_printf("softpll: sample_n %d seq %s mode %d "
"alignment_state %d HL%d ML%d HY=%d MY=%d EH=%d EM=%d ho=%d\n",
s->irq_count, stringlist_lookup(seq_states, s->seq_state),
s->mpll.sample_n, stringlist_lookup(seq_states, s->seq_state),
s->mode, s->ext.align_state,
s->helper.ld.locked, s->mpll.ld.locked,
s->helper.pi.y, s->mpll.pi.y,
......@@ -647,15 +650,24 @@ int spll_update()
stats.del_cnt = softpll.delock_count;
stats.sequence++;
if((SPLL->HO_CR & SPLL_HO_CR_HO_ACTIVE) > 0)
if ((SPLL->HO_CR & SPLL_HO_CR_HO_ACTIVE) > 0)
{
softpll.mpll.ld.ho_active = 1;
disable_irq();
if (softpll.mpll.ld.ho_active == 0)
{
spll_enable_tagger(MAIN_CHANNEL, 0);
softpll.mpll.ld.ho_active = 1;
}
//disable_irq();
mpll_update(&s->mpll, -1, -1);
}else
}
else
{
softpll.mpll.ld.ho_active = 0;
enable_irq();
if (softpll.mpll.ld.ho_active == 1)
{
softpll.mpll.ld.ho_active = 0;
spll_enable_tagger(MAIN_CHANNEL, 1);
// enable_irq();
}
}
softpll.mpll.ho_buf_div = SPLL->HO_RATE;
......
......@@ -121,7 +121,8 @@ int mpll_update(struct spll_main_state *s, int tag, int source)
if(!s->enabled)
return SPLL_LOCKED;
int err, y;
int err;
int y = s->pi.y;
if (source == s->id_ref)
s->tag_ref = tag;
......@@ -180,6 +181,7 @@ int mpll_update(struct spll_main_state *s, int tag, int source)
if(s->ld.ho_active){
if( !(s->sample_n % s->ho_buf_div) )
y = ho_update(s);
s->pi.y = y;
// ho_buf_pop(&s->ho_buf, &ho_value);
//s->pi.y=ho_value;
SPLL->DAC_HO = SPLL_DAC_HO_VALUE_W(y);
......@@ -229,6 +231,16 @@ int mpll_update(struct spll_main_state *s, int tag, int source)
}
if (ld_update((spll_lock_det_t *)&s->ld, err))
return SPLL_LOCKED;
}else if(s->ld.ho_active){
if( !(s->sample_n % s->ho_buf_div) )
y = ho_update(s);
s->pi.y = y;
// ho_buf_pop(&s->ho_buf, &ho_value);
//s->pi.y=ho_value;
SPLL->DAC_HO = SPLL_DAC_HO_VALUE_W(y);
s->sample_n++;
return SPLL_LOCKED;
}
return SPLL_LOCKING;
......@@ -359,7 +371,8 @@ int ho_update_1(struct spll_main_state *s)
int ho_update_2(struct spll_main_state *s)
{
return 30000;
int y=s->pi.y;
return y;
}
int ho_update_3(struct spll_main_state *s)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment