forked from M-Labs/artiq
jesd204sync: print DDMTD SYSREF final alignment delta
This commit is contained in:
parent
eebff6d77f
commit
1a42e23fb4
|
@ -172,18 +172,15 @@ fn max_phase_deviation(average: i32, phases: &[i32]) -> i32 {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reach_sysref_ddmtd_target(target: i32, tolerance: i32) -> Result<(), &'static str> {
|
fn reach_sysref_ddmtd_target(target: i32, tolerance: i32) -> Result<i32, &'static str> {
|
||||||
let mut phase = measure_ddmdt_phase();
|
for _ in 0..1024 {
|
||||||
let mut nslips = 0;
|
let delta = (measure_ddmdt_phase() - target + DDMTD_N) % DDMTD_N;
|
||||||
while (phase - target).abs() > tolerance {
|
if delta <= tolerance {
|
||||||
|
return Ok(delta)
|
||||||
|
}
|
||||||
hmc7043::sysref_slip();
|
hmc7043::sysref_slip();
|
||||||
nslips += 1;
|
|
||||||
if nslips > 1024 {
|
|
||||||
return Err("failed to reach SYSREF DDMTD phase target");
|
|
||||||
}
|
}
|
||||||
phase = measure_ddmdt_phase();
|
Err("failed to reach SYSREF DDMTD phase target")
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calibrate_sysref_target(rising_average: i32, falling_average: i32) -> Result<i32, &'static str> {
|
fn calibrate_sysref_target(rising_average: i32, falling_average: i32) -> Result<i32, &'static str> {
|
||||||
|
@ -275,11 +272,11 @@ pub fn sysref_auto_rtio_align() -> Result<(), &'static str> {
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("aligning SYSREF with RTIO clock...");
|
info!("aligning SYSREF with RTIO clock...");
|
||||||
reach_sysref_ddmtd_target(target_phase, 3)?;
|
let delta = reach_sysref_ddmtd_target(target_phase, 3)?;
|
||||||
if sysref_sh_error() {
|
if sysref_sh_error() {
|
||||||
return Err("SYSREF does not meet S/H timing at DDMTD phase target");
|
return Err("SYSREF does not meet S/H timing at DDMTD phase target");
|
||||||
}
|
}
|
||||||
info!(" ...done");
|
info!(" ...done, delta={}", delta);
|
||||||
|
|
||||||
sysref_rtio_align()?;
|
sysref_rtio_align()?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue