aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/cores
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-10-18 13:21:36 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:04:02 -0800
commitf2bcec594593bb2050a128a766510d500874b4f8 (patch)
treec5a3c6821caf9df039f16a45852294ccbb967035 /mpm/python/usrp_mpm/cores
parent99c5b6fff8426dd9f2fb8f0d26b12fc9405697f4 (diff)
downloaduhd-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/python/usrp_mpm/cores')
-rw-r--r--mpm/python/usrp_mpm/cores/tdc_sync.py19
1 files changed, 11 insertions, 8 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