Hi!
I somehow can't get counting on a digital input to work properly, if the function is called via a DMA handle:
@kernel
def run(self):
self.core.reset()
for i in range(10):
i = i + 1
# counting as dma function doesn't work
self.counter_dma(self.digital_in_devs[0])
counting_test_handle = self.core_dma.get_handle("counter_dma")
self.core.break_realtime()
self.core_dma.playback_handle(counting_test_handle)
# counting as a normal kernel method works
# self.core.break_realtime()
# self.counter(self.digital_in_devs[0])
@kernel
def counter_dma(self, device):
with self.core_dma.record("counter_dma"):
delay(1 * ms)
t_end = device.gate_rising(1 * ms)
print(device.count(t_end))
@kernel
def counter(self, device):
delay(1 * ms)
t_end = device.gate_rising(1 * ms)
print(device.count(t_end))
Calling the function via DMA yields somewhat random results, e.g. sometimes returning the correct value, sometimes returning 0, sometimes an exception with an overflow exception is raised. As an input, I used a function generator running at 50 kHz.
Calling the function not via DMA works fine, and yields the expected results.
Can anyone give me a hint, what I'm doing wrong here?
Many thanks for having a look!
Cheers!
Max
PS: I'm using artiq version 5.7111.5168b831 on the host PC and Kasli, and execute the
code using artiq_run in a nix environment on an Ubuntu system.