Hi, everyone!
How can I use PYNQ to read a GPIO value continuously?
Hi!
How fast? If you’re talking Python-fast, I think you could set up an AXI GPIO controller, and get python to read the mem-mapped interface.
For something faster to you would need to store the data in a buffer, so you would be limited by those resources. But then you could capture at 200hmhz+
Hi!
The frequency of value is about 250kHz. Actually I have used an AXI GPIO controller and I tried to use while loop to read the value. But it seems like while loop can’t catch up (can’t synchronize with) such a high frequency so I lost some values.
Here is my block design and the code in Python.
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 could you tell me how to store the data in a buffer or what’s the problem in my design and code?
Look up DMA on Pynq. It’s more complicated, and you will need extra stuff to control the DMA IP. But I think it’s the only way at 250 mhz.
Thanks.