datasheets/examples/pll.py

45 lines
987 B
Python
Raw Normal View History

2022-02-04 17:18:09 +08:00
from artiq.experiment import *
class MirnyEnv(EnvExperiment):
def build(self):
self.setattr_device("core")
self.cpld = self.get_device("mirny0_cpld")
self.pll0 = self.get_device("mirny0_ch0")
@kernel
def init_mirny(self):
self.core.reset()
self.cpld.init()
self.pll0.init()
self.pll0.set_frequency(1*GHz)
2022-02-07 14:26:58 +08:00
self.pll0.set_att(12*dB)
2022-02-04 17:18:09 +08:00
self.pll0.sw.on()
class PowerControl(MirnyEnv):
@kernel
def run(self):
self.core.reset()
self.init_mirny()
# Run other code here
delay(5*s)
self.pll0.set_output_power_mu(0)
print(self.pll0.output_power_mu())
class ToggleSwitch(MirnyEnv):
@kernel
def run(self):
self.core.reset()
self.init_mirny()
delay_mu(8) # Avoid RTIO collision
self.pll0.sw.off()
delay(1*s)
while True:
self.pll0.sw.pulse(100*us)
delay(900*us)