Part 2: Implementation of GPIO via MIO on ZedBoard by using Vivado


Abstract: In this tutorial, ZedBoard is used to implement GPIO via MIO. Here, the GPIOs i.e., two buttons, one LED, and Pmod E which are directly accessible in PS of ZedBoard are used to implement the MIO concept.

Implementation : There are following two ways to implement the above-mentioned GPIOs in Zedboard.

  1. Go to following GitHub link Click here for GitHub Link and follow the instructions given in this link.
  2. The second way is explained here:

Open Vivado, select the zedboard from Boards, and click on finish.

1

Create block design and click OK.

2

Select Zynq7 Processor System from search box and run Run Block Automation and click Ok

3
4

Double click on processing_system7_0, deselect the reset, AXI interface, clock and some peripherals (PS-PL configuration>General>Enable Clock Reset>FCLOCK_RESET0_N, PS-PL configuration>GP Master AXI Interface> M AXI GPO interface, Clock Configuration>PL Fabric Clocks>FCLK_CLK0, Peripheral I/O Pins>TTC0, and USB0), and click Ok. You would have the following beautiful figure.

5

validate you design, generate output products and create HDL wrapper

6

Lastly, export hardware and launch the SDK. In SDK environment create application project and select hello world and finish it. Copy the code following code and paste it into helloworld.c file

/***************************** Include Files ********************************/
#include “xparameters.h”
#include “xgpiops.h”
#include “xstatus.h”
#include <xil_printf.h>
#include “sleep.h”
/************************** Variable Definitions **************************/
XGpioPs Gpio;    /* The driver instance for GPIO Device. */
XGpioPs_Config *ConfigPtr;
/*****************************************************************************/
int main(void)
{
int Status;
u32 InputData;
 
/* Initialize the GPIO driver. */
ConfigPtr = XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);
Status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr,
ConfigPtr->BaseAddr);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
//GPIO_PS
XGpioPs_SetDirectionPin(&Gpio, 50, 0);
XGpioPs_SetOutputEnablePin(&Gpio, 50, 0);
XGpioPs_SetDirectionPin(&Gpio, 7, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 7, 1);
//PMOD//////////
//output
XGpioPs_SetDirectionPin(&Gpio, 0, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 0, 1);
XGpioPs_SetDirectionPin(&Gpio, 9, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 9, 1);
XGpioPs_SetDirectionPin(&Gpio, 10, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 10, 1);
XGpioPs_SetDirectionPin(&Gpio, 11, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 11, 1);
//output
XGpioPs_SetDirectionPin(&Gpio, 12, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 12, 1);
XGpioPs_SetDirectionPin(&Gpio, 13, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 13, 1);
XGpioPs_SetDirectionPin(&Gpio, 14, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 14, 1);
XGpioPs_SetDirectionPin(&Gpio, 15, 1);
XGpioPs_SetOutputEnablePin(&Gpio, 15, 1);
while(1){
// PS_GPIO
InputData = XGpioPs_ReadPin(&Gpio, 50);
usleep(100);
XGpioPs_WritePin(&Gpio, 7, InputData);
// PMOD E
XGpioPs_WritePin(&Gpio, 0, 1);
XGpioPs_WritePin(&Gpio, 9, 1);
XGpioPs_WritePin(&Gpio, 10,1);
XGpioPs_WritePin(&Gpio, 11,1);
XGpioPs_WritePin(&Gpio, 12,0);
XGpioPs_WritePin(&Gpio, 13,0);
XGpioPs_WritePin(&Gpio, 14,0);
XGpioPs_WritePin(&Gpio, 15,0);
usleep(100);
XGpioPs_WritePin(&Gpio, 0, 0);
XGpioPs_WritePin(&Gpio, 9, 0);
XGpioPs_WritePin(&Gpio, 10,0);
XGpioPs_WritePin(&Gpio, 11,0);
XGpioPs_WritePin(&Gpio, 12,1);
XGpioPs_WritePin(&Gpio, 13,1);
XGpioPs_WritePin(&Gpio, 14,1);
XGpioPs_WritePin(&Gpio, 15,1);
//printf(“yess”);
}
return XST_SUCCESS;
}

Finally, on the run icon click Run As> Launch On Hardware (System Debugger). Congratulation, you are able to control or monitor external signals via MIO on PS of Zedboad.

One thought on “Part 2: Implementation of GPIO via MIO on ZedBoard by using Vivado

  • I looked at your code and I want to know how you found the pin numbers that you reference? In the video, you mention a “manual”, however, the Zynq development board references many manuals. Can you please tell me the exact name of the manual you utilized and the page number to find your pin numbers on the zedboard? If you used the Vivado or SDK IDE to find your pin numbers, please let me know how you found them. Thank you.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s