Error reading OutputCurr setting of a DAC on RFSoC 4x2 with pynq-v3.0.1 base overlay

Hi,

I’m running the latest Pynq image v3.0.1 on RFSoC 4x2 and going through the example Jupyter Notebook base/rfdc/01_rf_dataconverter_introduction.ipynb .

I’m interested in reading/setting the DAC output current setting, however, evaluating base.radio.rfdc.dac_tiles[0].blocks[0].OutputCurr fails with the following error:

`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [66], in <cell line: 1>()
----> 1 base.radio.rfdc.dac_tiles[0].blocks[0].OutputCurr

File /usr/local/share/pynq-venv/lib/python3.10/site-packages/xrfdc/init.py:176, in _create_c_property.._get(self)
173 value = _ffi.new(f"{typename}*“)
174 c_func = self._call_function if not implicit_read else
175 self._call_function_implicit
→ 176 c_func(f"Get{name}”, value)
177 value = _unpack_value(value)
178 if isinstance(value, PropertyDict):

File /usr/local/share/pynq-venv/lib/python3.10/site-packages/xrfdc/init.py:270, in RFdcDacBlock._call_function_implicit(self, name, *args)
269 def _call_function_implicit(self, name, *args):
→ 270 return self._parent._call_function_implicit(name, self._index, *args)

File /usr/local/share/pynq-venv/lib/python3.10/site-packages/xrfdc/init.py:307, in RFdcTile._call_function_implicit(self, name, *args)
306 def _call_function_implicit(self, name, *args):
→ 307 return self._parent._call_function(name, self._index, *args)

File /usr/local/share/pynq-venv/lib/python3.10/site-packages/xrfdc/init.py:383, in RFdc._call_function(self, name, *args)
382 def _call_function(self, name, *args):
→ 383 safe_wrapper(f"XRFdc{name}", self._instance, *args)

File /usr/local/share/pynq-venv/lib/python3.10/site-packages/xrfdc/init.py:33, in _safe_wrapper(name, *args, **kwargs)
31 if not hasattr(_lib, name):
32 raise RuntimeError(f"Function {name} not in library")
—> 33 ret = getattr(_lib, name)(*args, **kwargs)
34 if ret:
35 message = f"Function {name} call failed"

TypeError: initializer for ctype ‘unsigned int *’ must be a pointer to same type, not cdata ‘int *’`

Any ideas how to work around this?

1 Like

Hi Sam,

I think you’ve managed to find a historic bug in the PYNQ xrfdc driver. The data type on this line here is incorrect. It should be u32, not int, as shown in the C driver here.

There is a quick and easy fix you can do that doesn’t even require power cycling the board. I’d suggest using this until a PR can be made for this issue. You should only need to do this once.

  1. Using the Jupyter interface on the RFSoC4x2 board, open a new terminal session (File → New → Terminal)
  2. Open the following file in a text editor (nano, vim, etc)
    vim /usr/local/share/pynq-venv/lib/python3.10/site-packages/xrfdc/__init__.py
  3. Navigate to line 79 and replace the data type "int" with "u32"
  4. Save the file and exit the text editor

You can then just restart the kernel of your notebook and run the cells again. You should be able to read from OutputCurr. Looking at the driver, this looks like a read only function, so you won’t be able to write to it.

Let me know if you need any more help with this issue.

Josh

That worked a treat, thanks Josh,

In [20]: base.radio.rfdc.dac_tiles[2].blocks[0].OutputCurr
Out[20]: 19993

This appears to correspond to the 20mA mode and I now see that by calling SetDACVOP(uACurrent) I can set this down as far as 2250 uA, with the generated tone power reducing accordingly.

Can you advise if it is safe to set the VOP higher than 20mA on the 4x2?

And whether the SNR would be improved in doing so?

Was great to meet you at the CASPER Workshop by the way, your support is much appreciated!

2 Likes

Hi Sam,

It was great to meet you too at the workshop, I’m glad to see you’ve been looking at PYNQ now.

I can’t give any advice outwith that from the documentation. According to PG269 the DACVOP current can be set between 2250 μA and 40500 μA. I’m not sure what is deemed a safe value though. You might find some useful information in DS926.

Hope this helps.

Josh

1 Like

Thanks Josh,

It turns out the RFSoC 4x2 with the Gen3 chip does accept the 40.5mA current setting, despite the note that DAC_AVTT must equal 3.0 V when it appears to be connected to 2.5 V.

The tone power appears to rise from -3.0 dBm (20 mA) to +2.5 dBm (40.5 mA), which not far off from the +6dB that I’d naively expect given the doubling of the current.

Thanks again,

Sam

Hi Sam,

Yes, you are right. Looking through the documentation and the board specs, the RFSoC4x2 does not support the DAC VOP as the DAC_AVTT is connected to 2.5 V.

Thanks,

Josh