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

**URL:** <https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308>\
**Category:** Support\
**Created:** [November 14, 2023, 12:51pm UTC](https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308 "2023-11-14T12:51:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam.rowe](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@sam.rowe](https://discuss.pynq.io/u/sam.rowe)\
**Post date:** [November 14, 2023, 12:51pm UTC](https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308/1 "2023-11-14T12:51:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![joshgoldsmith](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/joshgoldsmith/32/5347_2.png) [@joshgoldsmith](https://discuss.pynq.io/u/joshgoldsmith)\
**Post date:** [November 14, 2023, 3:16pm UTC](https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308/2 "2023-11-14T15:16:15Z")

</div>

Hi Sam,

I think you’ve managed to find a historic bug in the PYNQ `xrfdc` driver. The data type on this line [here](https://github.com/Xilinx/PYNQ/blob/de6b6fc3a803945d59f8f06523addfe0d9b60a1c/sdbuild/packages/xrfdc/package/xrfdc/ __init__.py#L79) is incorrect. It should be `u32`, not `int`, as shown in the C driver [here](https://github.com/Xilinx/PYNQ/blob/de6b6fc3a803945d59f8f06523addfe0d9b60a1c/sdbuild/packages/xrfdc/package/xrfdc/xrfdc_functions.c#L479).

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

---

<div class="post-metadata">

**Author:** ![sam.rowe](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@sam.rowe](https://discuss.pynq.io/u/sam.rowe)\
**Post date:** [November 14, 2023, 4:28pm UTC](https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308/3 "2023-11-14T16:28:56Z")

</div>

That worked a treat, thanks Josh,

```auto
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!

---

<div class="post-metadata">

**Author:** ![joshgoldsmith](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/joshgoldsmith/32/5347_2.png) [@joshgoldsmith](https://discuss.pynq.io/u/joshgoldsmith)\
**Post date:** [November 14, 2023, 5:53pm UTC](https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308/4 "2023-11-14T17:53:57Z")

</div>

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](https://docs.xilinx.com/r/en-US/pg269-rf-data-converter/XRFdc_SetDACVOP-Gen-3/DFE) 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](https://docs.xilinx.com/r/en-US/ds926-zynq-ultrascale-plus-rfsoc).

Hope this helps.

Josh

---

<div class="post-metadata">

**Author:** ![sam.rowe](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@sam.rowe](https://discuss.pynq.io/u/sam.rowe)\
**Post date:** [November 16, 2023, 5:03pm UTC](https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308/5 "2023-11-16T17:03:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joshgoldsmith](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/joshgoldsmith/32/5347_2.png) [@joshgoldsmith](https://discuss.pynq.io/u/joshgoldsmith)\
**Post date:** [November 20, 2023, 4:46pm UTC](https://discuss.pynq.io/t/error-reading-outputcurr-setting-of-a-dac-on-rfsoc-4x2-with-pynq-v3-0-1-base-overlay/6308/6 "2023-11-20T16:46:54Z")

</div>

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
