diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-10-18 13:21:36 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:04:02 -0800 |
commit | f2bcec594593bb2050a128a766510d500874b4f8 (patch) | |
tree | c5a3c6821caf9df039f16a45852294ccbb967035 /mpm | |
parent | 99c5b6fff8426dd9f2fb8f0d26b12fc9405697f4 (diff) | |
download | uhd-f2bcec594593bb2050a128a766510d500874b4f8.tar.gz uhd-f2bcec594593bb2050a128a766510d500874b4f8.tar.bz2 uhd-f2bcec594593bb2050a128a766510d500874b4f8.zip |
mpm: Replace MMCM lock and TDC PPS sleeps with poll_with_timeout
This increases init speed by replacing worst-case sleeps with polls.
Diffstat (limited to 'mpm')
-rw-r--r-- | mpm/python/usrp_mpm/cores/tdc_sync.py | 19 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/magnesium.py | 11 |
2 files changed, 18 insertions, 12 deletions
diff --git a/mpm/python/usrp_mpm/cores/tdc_sync.py b/mpm/python/usrp_mpm/cores/tdc_sync.py index 01724852d..dadd78ac5 100644 --- a/mpm/python/usrp_mpm/cores/tdc_sync.py +++ b/mpm/python/usrp_mpm/cores/tdc_sync.py @@ -21,6 +21,7 @@ import time import math from builtins import object from functools import reduce +from usrp_mpm.mpmutils import poll_with_timeout def mean(vals): " Calculate arithmetic mean of vals " @@ -183,15 +184,17 @@ class ClockSynchronizer(object): # across all devices. self.poke32(self.TDC_CONTROL, 0x10) - # Since a PPS rising edge comes once per second... we only need to wait slightly - # longer than a second to confirm the TDC received a PPS. - # TODO change this to a polling operation - time.sleep(1.1) - pps_status = self.peek32(self.TDC_STATUS) & 0xFF - if pps_status != 0x10: - self.log.error("Failed to capture PPS within 1.1 seconds. Status: 0x{:x}".format(pps_status)) + # Since a PPS rising edge comes once per second, we need to wait + # slightly longer than a second (worst-case) to confirm the TDC + # received a PPS. + if not poll_with_timeout( + lambda: bool(self.peek32(self.TDC_STATUS) & 0xFF != 0x10), + 1100, # Try for 1.1 seconds + 100, # Poll every 100 ms + ): + self.log.error("Failed to capture PPS within 1.1 seconds. " \ + "TDC_STATUS: 0x{:X}".format(pps_status)) raise RuntimeError("Failed to capture PPS.") - self.log.trace("PPS Captured!") meas_clk_freq = 170.542641116e6 diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py index 48934af1f..b71be6901 100644 --- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py +++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py @@ -34,6 +34,7 @@ from usrp_mpm.periph_manager.udev import get_eeprom_paths from usrp_mpm.cores import ClockSynchronizer from ..sysfs_gpio import SysFSGPIO from usrp_mpm.bfrfs import BufferFS +from usrp_mpm.mpmutils import poll_with_timeout def create_spidev_iface(dev_node): """ @@ -595,12 +596,14 @@ class DboardClockControl(object): """ self.log.trace("Un-resetting MMCM...") self.poke32(self.RADIO_CLK_MMCM, 0x2) - time.sleep(0.5) # Replace with poll and timeout TODO - mmcm_locked = bool(self.peek32(self.RADIO_CLK_MMCM) & 0x10) - if not mmcm_locked: + if not poll_with_timeout( + lambda: bool(self.peek32(self.RADIO_CLK_MMCM) & 0x10), + 500, + 10, + ): self.log.error("MMCM not locked!") raise RuntimeError("MMCM not locked!") - self.log.trace("Enabling output MMCM clocks...") + self.log.trace("MMCM locked. Enabling output MMCM clocks...") self.enable_outputs(True) def check_refclk(self): |