PYNQ: PYTHON PRODUCTIVITY

How to use PYNQ to read the high frequency value from GPIO continuously?

Hello, I tried to read the value generated by INMP441(a kind of mic). I used AXIGPIO in block design and Overlay in PYNQ, and tried to use while loop to read the value continuously.

But the value has the very high frequency() and it seems like while loop can’t catch up such a high frequency which will lead to loss data.

Here is the block design.

Here is the code in PYNQ.

from pynq import Overlay
from pynq.lib import AxiGPIO
from time import sleep
from pynq import GPIO

data = []

overlay = Overlay('/home/xilinx/pynq/overlays/overlay_1230/test1230_1725.bit')

input_ip = overlay.ip_dict['led2']
ipt = AxiGPIO(input_ip).channel1
ipt.setdirection("in")

while 1:
    data.append(ipt.read())

So if there is anyway to use PYNQ to read the high frequency value from GPIO continuously?

The frequency of value is about 250kHz.

250KHz should be fine; the upperbound for GPIO pin frequency is around 10MHz or so.

The problem is the python code. You used that data.append() to construct the list dynamically. Each read will incur a long latency from Python down to AXI GPIO read. I think the right way to do it is to read a batch of data together and return it back to your Python level.