dds.c: turn off batch mode before an underflow can be raised.

Fixes #334.
This commit is contained in:
whitequark 2016-03-18 04:54:15 +00:00
parent f4ab507ab2
commit dbc0a89903
2 changed files with 34 additions and 1 deletions

View File

@ -192,6 +192,7 @@ void dds_batch_exit(void)
if(!batch_mode)
artiq_raise_from_c("DDSBatchError", "DDS batch error", 0, 0, 0);
batch_mode = 0;
/* + FUD time */
now = batch_ref_time - batch_count*(DURATION_PROGRAM + DURATION_WRITE);
for(i=0;i<batch_count;i++) {
@ -201,7 +202,6 @@ void dds_batch_exit(void)
batch[i].amplitude);
now += DURATION_PROGRAM + DURATION_WRITE;
}
batch_mode = 0;
}
void dds_set(long long int timestamp, int bus_channel, int channel,

View File

@ -102,6 +102,32 @@ class PulseRate(EnvExperiment):
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):
def build(self):
self.setattr_device("core")
@ -228,6 +254,13 @@ class CoredeviceTest(ExperimentCase):
self.assertGreater(rate, 100*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):
npulses = 2
self.execute(LoopbackCount, npulses=npulses)