element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Path to Programmable 3
  • Challenges & Projects
  • Design Challenges
  • Path to Programmable 3
  • More
  • Cancel
Path to Programmable 3
Blog 1. LED Blinking Part 1: 4-bit ARM
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Path to Programmable 3 to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: rajivbishwokarma
  • Date Created: 27 Jul 2023 6:33 AM Date Created
  • Views 663 views
  • Likes 4 likes
  • Comments 0 comments
  • Ultra96-V2 Board
  • Path to Programmable 3
  • vitis
  • Training blog
Related
Recommended

1. LED Blinking Part 1: 4-bit ARM

rajivbishwokarma
rajivbishwokarma
27 Jul 2023

1. Introduction

In this blog, we will use the Processing System (PS) side to blink the 4 user programmable LEDs that are available in the Ultra96v2. This is a really simple introduction to how we can initialize the Zynq US+ block in the Vivado design and then create a software application to run on the ARM processor inside the Ultra96v2.

All the files for this blog are available here: https://github.com/rajivbishwokarma/element14_p2p_blogs

2. Setting up hardware in Vivado

The block design is a very very simple with just a Zynq UltraScale+ block as shown below. We then can double click to customize it and uncheck of the HPM interfaces under PS-PL Interface as we won’t be needing those.

image

image

We can then generate the hardware and include bitstream in it as that is all we need from Vivado.

3. Blinking the LEDs using Vitis

Then in Vitis, we can create a hello world project using the hardware platform file that we obtained from Vivado and use the following code to blink the f4 user programmable LEDs as shown in the video below.

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xgpiops.h"
#include "xil_printf.h"
#include "sleep.h"

#define GPIO_DEVICE_ID XPAR_PSU_GPIO_0_DEVICE_ID  // The device ID for the GPIO device

int main() {
	int LED[4] = {17, 18, 19, 20};
	int led_ctr = 0;
    XGpioPs Gpio;
    XGpioPs_Config *ConfigPtr;
    int Status;

    // Initialize the GPIO driver
    ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);
    if (ConfigPtr == NULL) {
        xil_printf("GPIO Lookup failed\n");
        return XST_FAILURE;
    }

    Status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr, ConfigPtr->BaseAddr);
    if (Status != XST_SUCCESS) {
        xil_printf("GPIO Initialization failed\n");
        return XST_FAILURE;
    }

    for (int i = 0; i <= 3; i++) {
    	/* Set the direction and enable output */
    	XGpioPs_SetDirectionPin(&Gpio, LED[i], 0x1);
  	    XGpioPs_SetOutputEnablePin(&Gpio, LED[i], 0x1);
  	    XGpioPs_WritePin(&Gpio, LED[i], 0);
    }


    while(1) {
        XGpioPs_WritePin(&Gpio, LED[led_ctr], 1);
        xil_printf("LED ON!");
        sleep(1);
        XGpioPs_WritePin(&Gpio, LED[led_ctr], 0);
        xil_printf("LED OFF!");
        sleep(1);

        led_ctr++;
        if (led_ctr == 4) { led_ctr = 0;}
    }

    return 0;
}

Result. 

The demo of the project can be found here. 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

5. Conclusion

In the first blog we created a very simple design and blinked the four LEDs connected to the PS side of the Ultra96v2 SBC. In the next one, we will extend this to include the FPGA.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube