Jump to content
  • 0

Zybo: Access the LD_MIO LED from the FPGA




I have a Zybo board and am using Vivado 2017.2. I have successfully written a number of VHDL modules allowing me to access the boards push-buttons, LEDs and slide switches using only the PL part of the device.

I wondered if it was all possible to drive the LD_MIO LED from the FPGA?

From my understanding it should be possible using the EMIO but have not been able to find an example or tutorial that shows how it is done.



Link to comment
Share on other sites

2 answers to this question

Recommended Posts


I am currently using Vivado 2016.4, but to my knowledge, this should work in 2017.2 as well (hopefully). In your block design, go to recustomize the Zynq block (double click on it). Go to Peripheral I/O Pins in the Page Navigator. Scroll to the bottom of the page or until you can see the GPIO MIO line in the table. If the check box next to it is checked and column 7 is highlighted, then the configuration is fine, and this will only require writing C code (the attached image is the correct configuration here). If not, check the box, hit OK, and re-generate the bitstream. I believe that the highlighted values are set by the Zybo board file, but could be wrong.

In SDK, the MIO GPIO pins use the gpiops driver, rather than the standard gpio driver. The following code worked for me to blink the led.

#include "xparameters.h"
#include "xgpiops.h"
#include "sleep.h"

int main() {
    XGpioPs led;

    XGpioPs_CfgInitialize(&led, &ledcfg, ledcfg.BaseAddr); // initialize the driver device
    XGpioPs_SetOutputEnablePin(&led, 7, 0b1); // set MIO7 as output
    XGpioPs_SetDirectionPin(&led, 7, 0b1); // set MIO7 tristate as output (idk if both are required)
    XGpioPs_IntrDisablePin(&led, 7); // disable interrupts on MIO7, (just in case)

    while (1) {
		XGpioPs_WritePin(&led, 7, 0b1); // set MIO7 high
		sleep(1); // wait a second
		XGpioPs_WritePin(&led, 7, 0b0); // set MIO7 low

Hope this helps,



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...