Experiment using Vivado zedboard GPIO switch on control LED

Source: Internet
Author: User
Tags vivado

I did a few experiments in front of the switch, this time with a

Discover Vivado is really handy so use Vivado to develop

1. Construction works

I use Vivado 2013.4

Create a new project – "next–" next

Tick specify sources at this time//to skip the next two Add file pages

Choose board– "zedboard–" next– "Finsh

was created.

2.PL End IP Core Add and connect

Create an empty Diagram

Create Block Design-"Dot ok"

Next add IP Core can click Prompt add IP can also click

Search Zynq Point First

Then click Run Block Automation automatic configuration

Click Add GPIO

Next you will be prompted to Run Connection Automation automatic connection

Choose S_axi to become

The system automatically adds some IP cores

Continue to click on Run Connection Automation-"GPIO

Select Led_8bits-"OK

Same method Add GPIO IP Core-"Run Connection Automation two times Select Sws_8bits

It's done.

Click on the red circle to verify it.

3. The process of generating a bit

Click on Source-"design_1 right-" Create HDL Wrapper-"OK

Then Synthesis, implementation, and Bitstream went through it in turn.

This process costs time. Synthesis always click OK and then Generate bitstream

4. Output to SDK

Select the Launch SDK click OK to launch the SDK

My SDK is

Click file– "new–> Application project

Pick a HelloWorld.

Copy the following code

1#include <stdio.h>2#include"platform.h"3#include"Xparameters.h"4#include"xgpio.h"5#include"Sleep.h"6#include"platform.h"7#include"Xil_types.h"8#include"Xgpiops.h"9 Ten  One /************************** Constant Definitions *****************************/ A  - /* - * The following constant maps to the name of the hardware instances that the * were created in the EDK XPS system. -  */ - #definexpar_leds_id xpar_axi_gpio_0_baseaddr//Axi_gpio_0 is the first GPIO added so it is the LEDs - #definexpar_sws_id xpar_axi_gpio_1_baseaddr//so this is a switch, naturally. +  - intMain () + { A     StaticXgpio led_ptr;//Defining Gpio Pointers at     StaticXgpio sws_ptr; -     intxstatus; -     intnum =0; -     //Initializing LEDs -Xstatus = Xgpio_initialize (&led_ptr,xpar_axi_gpio_0_device_id); -     if(Xst_success! =xstatus) inPrint"GPIO INIT failed\n\r"); -Xgpio_setdatadirection (&led_ptr,1,0x00);//Channel 1; set direction 0 Output 1 input, 0x00 means 8 bits are output toXgpio_discretewrite (&led_ptr,1,0x00); +  -     //Initialize Switch theXstatus = Xgpio_initialize (&sws_ptr,xpar_axi_gpio_1_device_id); *     if(Xst_success! =xstatus) $Print"GPIO INIT failed\n\r");Panax NotoginsengXgpio_setdatadirection (&sws_ptr,1,0xFF);//Channel 1; set direction 0 Output 1 input 0xFF means 8 bit is input -  the  +  A      while(1){ thenum = Xgpio_discreteread (&sws_ptr,1);//read data from the switch +printf"Numb%d\n\r", num); -Xgpio_discretewrite (&led_ptr,1, num);//Direct Write led $Usleep +);//Delay 1ms $     } -  -printf"end\n\r \n\r"); the     return 0; -}

Make sure the Zedboard is connected to the computer and powered on

First Xilinx tools–> PROGRAMFPGA

Then Run as–> Launch on Hardware (GDB)

can see results 64 + 1

The 7th and 1th switches are open.

So the LEDs are lit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.