mirror of https://github.com/m-labs/artiq.git
dds.c: turn off batch mode before an underflow can be raised.
Fixes #334.
This commit is contained in:
parent
f4ab507ab2
commit
dbc0a89903
|
@ -192,6 +192,7 @@ void dds_batch_exit(void)
|
||||||
|
|
||||||
if(!batch_mode)
|
if(!batch_mode)
|
||||||
artiq_raise_from_c("DDSBatchError", "DDS batch error", 0, 0, 0);
|
artiq_raise_from_c("DDSBatchError", "DDS batch error", 0, 0, 0);
|
||||||
|
batch_mode = 0;
|
||||||
/* + FUD time */
|
/* + FUD time */
|
||||||
now = batch_ref_time - batch_count*(DURATION_PROGRAM + DURATION_WRITE);
|
now = batch_ref_time - batch_count*(DURATION_PROGRAM + DURATION_WRITE);
|
||||||
for(i=0;i<batch_count;i++) {
|
for(i=0;i<batch_count;i++) {
|
||||||
|
@ -201,7 +202,6 @@ void dds_batch_exit(void)
|
||||||
batch[i].amplitude);
|
batch[i].amplitude);
|
||||||
now += DURATION_PROGRAM + DURATION_WRITE;
|
now += DURATION_PROGRAM + DURATION_WRITE;
|
||||||
}
|
}
|
||||||
batch_mode = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dds_set(long long int timestamp, int bus_channel, int channel,
|
void dds_set(long long int timestamp, int bus_channel, int channel,
|
||||||
|
|
|
@ -102,6 +102,32 @@ class PulseRate(EnvExperiment):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
class PulseRateDDS(EnvExperiment):
|
||||||
|
def build(self):
|
||||||
|
self.setattr_device("core")
|
||||||
|
self.setattr_device("core_dds")
|
||||||
|
self.setattr_device("dds0")
|
||||||
|
self.setattr_device("dds1")
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def run(self):
|
||||||
|
dt = seconds_to_mu(150*us)
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
delay(10*ms)
|
||||||
|
for i in range(100):
|
||||||
|
with self.core_dds.batch:
|
||||||
|
self.dds0.set(100*MHz)
|
||||||
|
self.dds1.set(100*MHz)
|
||||||
|
delay_mu(dt)
|
||||||
|
except RTIOUnderflow:
|
||||||
|
dt += 100
|
||||||
|
self.core.break_realtime()
|
||||||
|
else:
|
||||||
|
self.set_dataset("pulse_rate", mu_to_seconds(2*dt))
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
class Watchdog(EnvExperiment):
|
class Watchdog(EnvExperiment):
|
||||||
def build(self):
|
def build(self):
|
||||||
self.setattr_device("core")
|
self.setattr_device("core")
|
||||||
|
@ -228,6 +254,13 @@ class CoredeviceTest(ExperimentCase):
|
||||||
self.assertGreater(rate, 100*ns)
|
self.assertGreater(rate, 100*ns)
|
||||||
self.assertLess(rate, 2500*ns)
|
self.assertLess(rate, 2500*ns)
|
||||||
|
|
||||||
|
def test_pulse_rate_dds(self):
|
||||||
|
self.execute(PulseRateDDS)
|
||||||
|
rate = self.dataset_mgr.get("pulse_rate")
|
||||||
|
print(rate)
|
||||||
|
self.assertGreater(rate, 100*us)
|
||||||
|
self.assertLess(rate, 2500*us)
|
||||||
|
|
||||||
def test_loopback_count(self):
|
def test_loopback_count(self):
|
||||||
npulses = 2
|
npulses = 2
|
||||||
self.execute(LoopbackCount, npulses=npulses)
|
self.execute(LoopbackCount, npulses=npulses)
|
||||||
|
|
Loading…
Reference in New Issue