From 3f32d78c0efc9b4067baead3f93d995d2c70d1e4 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 31 Dec 2019 12:12:03 +0800 Subject: [PATCH] wrpll: simple ADPLL test --- artiq/firmware/libboard_artiq/wrpll.rs | 18 ++++++++++++++++++ artiq/firmware/satman/main.rs | 2 ++ 2 files changed, 20 insertions(+) diff --git a/artiq/firmware/libboard_artiq/wrpll.rs b/artiq/firmware/libboard_artiq/wrpll.rs index b42166670..bf935f36a 100644 --- a/artiq/firmware/libboard_artiq/wrpll.rs +++ b/artiq/firmware/libboard_artiq/wrpll.rs @@ -262,6 +262,13 @@ mod si549 { Ok(()) } + + pub fn adpll(dcxo: i2c::Dcxo, adpll: i32) -> Result<(), &'static str> { + write(dcxo, 231, adpll as u8)?; + write(dcxo, 232, (adpll >> 8) as u8)?; + write(dcxo, 233, (adpll >> 16) as u8)?; + Ok(()) + } } fn get_frequencies() -> (u32, u32, u32) { @@ -321,8 +328,19 @@ pub fn init() { unsafe { csr::wrpll::helper_reset_write(0); } clock::spin_us(1); +} +pub fn diagnostics() { log_frequencies(); + + info!("ADPLL test:"); + // +/-10ppm + si549::adpll(i2c::Dcxo::Helper, -85911).expect("ADPLL write failed"); + si549::adpll(i2c::Dcxo::Main, 85911).expect("ADPLL write failed"); + log_frequencies(); + si549::adpll(i2c::Dcxo::Helper, 0).expect("ADPLL write failed"); + si549::adpll(i2c::Dcxo::Main, 0).expect("ADPLL write failed"); + let mut tags = [0; 10]; for i in 0..tags.len() { tags[i] = get_ddmtd_main_tag(); diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index 5225eba1b..3b5096fd8 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -463,6 +463,8 @@ pub extern fn main() -> i32 { csr::drtio_transceiver::stable_clkin_write(1); } clock::spin_us(1500); // wait for CPLL/QPLL lock + #[cfg(has_wrpll)] + wrpll::diagnostics(); init_rtio_crg(); #[cfg(has_hmc830_7043)]