SYSREF on RFSoC 2x2

Hi, I am trying to sync the DAC output with an external clock. I’ve been looking through the manual and xrfdc code to help, but am nonetheless having difficulties. My understanding is that (within the base overlay) I can change the mixer settings in the DAC to have:

channel.dac_block.MixerSettings[‘EventSource’] = xrfdc.EVNT_SRC_SYSREF

Then, the mixer should now update relative to the sys ref. But, I get the error:

RuntimeError: Function XRFdc_UpdateEvent call failed
stdout: metal: error:
Invalid Event Source (1), this should be issued external to the driver for DAC 0 block 0 in XRFdc_UpdateEvent

It says I should be changing the event source outside of the DAC, but it is unclear to me where I should do this. Is there anyway using the base overlay and pynq python wrapper to adjust the clocking source? If so, what code could I run to do so? Any help is appreciated!

1 Like

Hi there,

Don’t think I’ve encountered this myself. Do you have a small reproducible example of how you’re calling the code? Are you doing it like in e.g. the QPSK demo here? There’s one code snippet of the procedure for using sysref in the rfdc manual, p180 that might be a useful reference to look at. Hope this helps.

Thanks
Shawn

Hi Shawn,

I don’t think this is exactly like the QPSK demo and may even be more basic. I am trying to follow the steps on page 180 for MTS. I added the following to xrfdc init.py as part of the RFdc class.

    def RunMTS(self):
        self._DAC_Sync_Config = _ffi.new("XRFdc_MultiConverter_Sync_Config*")
        self._ADC_Sync_Config = _ffi.new("XRFdc_MultiConverter_Sync_Config*")

        _lib.XRFdc_MultiConverter_Init(self._DAC_Sync_Config, _ffi.new("int*"), _ffi.new("int*"))

        self._DAC_Sync_Config.Tiles = 0x3
        self._DAC_Sync_Config.SysRef_Enable = 1
        self._DAC_Sync_Config.Target_Latency = 296
        print(self._DAC_Sync_Config.Target_Latency)
        self.status1 = _lib.XRFdc_MultiConverter_Sync(self._instance, _lib.XRFDC_DAC_TILE,self._DAC_Sync_Config)

        print(self.status1)
    def sysrefDisable(self):
        self.enable[0]=0
        self.status3 = _lib.XRFdc_MTS_Sysref_Config(self._instance, self._DAC_Sync_Config,self._ADC_Sync_Config, self.enable[0])
        print(self.status3)

    def sysrefEnable(self):
        self.enable[0]=1
        self.status3 = _lib.XRFdc_MTS_Sysref_Config(self._instance, self._DAC_Sync_Config, self._ADC_Sync_Config, self.enable[0])
        print(self.status3)

    def printLatency(self):
        for i in range(2):
            print("Dac Latency: "+str(self._DAC_Sync_Config.Latency[i]))
            print("Dac offset: "+str(self._DAC_Sync_Config.Offset[i]))
        print("*****")

Then, in my data collection I run

base = BaseOverlay('base.bit')
base.init_rf_clks()
base.radio.rfdc.RunMTS()

freq=60.40
gain=0.33

base.radio.rfdc.sysrefEnable()
dac00=base.radio.transmitter.channel[0].dac_block
dac01=base.radio.transmitter.channel[1].dac_block

base.radio.transmitter.channel[0].control.enable = True
base.radio.transmitter.channel[0].control.gain = gain

base.radio.transmitter.channel[1].control.enable = True
base.radio.transmitter.channel[1].control.gain = gain

dac00.NyquistZone = 1
dac00.MixerSettings['EventSource'] = xrfdc.EVNT_SRC_SYSREF
dac00.MixerSettings['Freq'] = freq
base.radio.rfdc.dac_tiles[0].SetupFIFO(True)


dac01.NyquistZone = 1
dac01.MixerSettings['EventSource'] = xrfdc.EVNT_SRC_SYSREF
dac01.MixerSettings['Freq'] = freq
base.radio.rfdc.dac_tiles[1].SetupFIFO(True)

base.radio.rfdc.printLatency()

which gives output:
Dac Latency: 0
Dac offset: 0
Dac Latency: 0
Dac offset: 0


The zero latencies are definitely a sign that this is not working. I also have the outputs connected to an oscilloscope and can see that they are not synced :confused: Do you see an reason this is failing?

Thank you!
Tommy

P.S. Credit to fjtoralza as my code is largely drawn from their post.