You are here

Reading GPIO pins and passing the data to computer over USB | Cypress Semiconductor

Reading GPIO pins and passing the data to computer over USB

Summary: 2 Replies, Latest post by chetgnegy_1631956 on 26 May 2016 09:25 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
chetgnegy_1631956's picture
2 posts

This is my first serious embedded experience (I have played with Raspberry Pi and Arduino, so I'm not completely new) so please forgive what could be very easy questions.

I need to read several (16) binary signals through the GPIO pins (clocked at ~3MHz), pass them through the USB3 port and dump them into a file on my computer. I have played around with the GpioApp demo and can make pins turn on and off, but that's about it. I'm finding the amount of setup for even the simplest things to be a bit daunting. Is there a better demo to start with? Just how difficult of a task should I expect this to be?

mady's picture
Cypress Employee
964 posts


In the FX3 SDK, there is an example project called GpiftoUSb. It is used to sample binary signals from the 32 Bit GPIF Paralllel bus (can be configured to 16 Bus as per your requirement. Contact Cypress Tech Support for the same)

The current example is such that is samples the signals on the raw unconnected pins and is read by PC using our host application called streamer. (whose source code is available in FX3 SDK).

You can edit the streamer source code to dump the read data into a File on the disk. We provide a sample code for storing the read data on the disk. Please contact the Tech Support to get this code as well.


- Madhu Sudhan

chetgnegy_1631956's picture
2 posts

As a followup, here's what needed to be done to get this working.

The clock frequency is so low (~3MHz) relative to the GPIF clock (100MHz), we can just read in the data asynchronously with respect to the external clock. It will be highly oversampled. To avoid reading in the data at the oversampled rate, the GPIFII designer can be used. (New project, set up a 32 bit bus, and make a DACK special signal on one of the CTL pins). I developed a state machine that read once once it saw a DACK assertion and then goes into an idle state until DACK is no longer asserted. These states just loop so that it is as if the data is being sampled on the rising edge. Note that if your data is also changing on the rising edge, it may not be read in reliably. To maximize hold times, change your data only on the DACK falling edge and read it on the rising edge as set up by the state machine. Build the state machine and get the created gpif2config.h file and copy that into the gpiftousb firmware project.

Build the firmware and flash it to the device. The streamer can be used to read the data in.

Log in to post new comments.