forked from M-Labs/nac3
1
0
Fork 0
nac3/examples/dma.py

27 lines
771 B
Python
Raw Normal View History

from artiq.experiment import *
class DMAPulses(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("core_dma")
self.setattr_device("led0")
@kernel
def record(self):
2020-07-30 22:25:14 +08:00
with self.core_dma.record("pulse"):
delay(200*ms)
# all RTIO operations now go to the "pulse"
# DMA buffer, instead of being executed immediately.
2020-07-30 22:25:14 +08:00
self.led0.pulse(500*ms)
@kernel
def run(self):
self.core.reset()
self.record()
# prefetch the address of the DMA buffer
# for faster playback trigger
2020-07-30 22:25:14 +08:00
pulse_handle = self.core_dma.get_handle("pulse")
self.core.break_realtime()
2020-07-30 22:25:14 +08:00
self.core_dma.playback_handle(pulse_handle)