From cfb21ca126fcd3d44b777939ee959e23e4ab11df Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 17 Feb 2018 13:52:01 +0800 Subject: [PATCH] si5324: fix usage of external CLKIN2 reference --- artiq/firmware/libboard_artiq/si5324.rs | 7 +++++-- artiq/firmware/runtime/main.rs | 10 ++++++---- artiq/firmware/satman/main.rs | 3 ++- artiq/gateware/targets/kasli.py | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/artiq/firmware/libboard_artiq/si5324.rs b/artiq/firmware/libboard_artiq/si5324.rs index 69ed734db..acf6a2678 100644 --- a/artiq/firmware/libboard_artiq/si5324.rs +++ b/artiq/firmware/libboard_artiq/si5324.rs @@ -43,7 +43,8 @@ pub struct FrequencySettings { pub n2_ls: u32, pub n31: u32, pub n32: u32, - pub bwsel: u8 + pub bwsel: u8, + pub crystal_ref: bool } fn map_frequency_settings(settings: &FrequencySettings) -> Result { @@ -201,7 +202,9 @@ pub fn setup(settings: &FrequencySettings) -> Result<()> { #[cfg(si5324_soft_reset)] soft_reset()?; - write(0, read(0)? | 0x40)?; // FREE_RUN=1 + if settings.crystal_ref { + write(0, read(0)? | 0x40)?; // FREE_RUN=1 + } write(2, (read(2)? & 0x0f) | (s.bwsel << 4))?; write(21, read(21)? & 0xfe)?; // CKSEL_PIN=0 write(3, (read(3)? & 0x3f) | (0b01 << 6) | 0x10)?; // CKSEL_REG=b01 SQ_ICAL=1 diff --git a/artiq/firmware/runtime/main.rs b/artiq/firmware/runtime/main.rs index 364f801e9..45e856526 100644 --- a/artiq/firmware/runtime/main.rs +++ b/artiq/firmware/runtime/main.rs @@ -111,7 +111,6 @@ fn startup() { fn setup_si5324_free_running() { // 125MHz output, from 100MHz CLKIN2 reference, 9 Hz - // FIXME: needs !FREE_RUN at address 0x00 #[cfg(all(rtio_frequency = "125.0", si5324_ext_ref))] const SI5324_SETTINGS: board_artiq::si5324::FrequencySettings = board_artiq::si5324::FrequencySettings { @@ -121,7 +120,8 @@ fn setup_si5324_free_running() n2_ls : 260, n31 : 65, n32 : 52, - bwsel : 10 + bwsel : 10, + crystal_ref: false }; // 125MHz output, from crystal, 7 Hz #[cfg(all(rtio_frequency = "125.0", not(si5324_ext_ref)))] @@ -133,7 +133,8 @@ fn setup_si5324_free_running() n2_ls : 19972, n31 : 4993, n32 : 4565, - bwsel : 4 + bwsel : 4, + crystal_ref: true }; // 150MHz output, from crystal #[cfg(all(rtio_frequency = "150.0", not(si5324_ext_ref)))] @@ -145,7 +146,8 @@ fn setup_si5324_free_running() n2_ls : 33732, n31 : 9370, n32 : 7139, - bwsel : 3 + bwsel : 3, + crystal_ref: true }; board_artiq::si5324::setup(&SI5324_SETTINGS).expect("cannot initialize Si5324"); } diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index 99de319cf..cdaebff47 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -183,7 +183,8 @@ const SI5324_SETTINGS: si5324::FrequencySettings n2_ls : 33732, n31 : 9370, n32 : 7139, - bwsel : 3 + bwsel : 3, + crystal_ref: true }; fn drtio_link_is_up() -> bool { diff --git a/artiq/gateware/targets/kasli.py b/artiq/gateware/targets/kasli.py index 2fd9058ae..72b147064 100755 --- a/artiq/gateware/targets/kasli.py +++ b/artiq/gateware/targets/kasli.py @@ -230,7 +230,7 @@ class Opticlock(_StandaloneBase): _StandaloneBase.__init__(self, **kwargs) self.config["SI5324_FREE_RUNNING"] = None - # self.config["SI5324_EXT_REF"] = None + self.config["SI5324_EXT_REF"] = None self.config["RTIO_FREQUENCY"] = "125.0" platform = self.platform