element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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 2. LED Blinking Part 2: FPGA flashes Police Lights
  • 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:39 AM Date Created
  • Views 1153 views
  • Likes 5 likes
  • Comments 2 comments
  • AMD XILINX
  • fpga
  • Ultra96-V2 Board
  • Path to Programmable 3
Related
Recommended

2. LED Blinking Part 2: FPGA flashes Police Lights

rajivbishwokarma
rajivbishwokarma
27 Jul 2023

1. Introduction

In the last blog, we just used the Processing System (PS) side to blink the 4 user programmable LEDs, so we will build on that and see how we can incorporate the PL side LEDs and extend our design to use both the PS and the PL. In this blog we will try to replicate the flashing lights of a police car lights using the Ultra96v2 FPGA board.

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 simple block design using an external GPIO port connected to the Zynq US+ block through the AXI GPIO IP. Figure 1 shows the complete block design for the system.

image

image

Once this is done and the design is validated to have no error, then we can go ahead and assign the physical PIN locations to our “gpio_led[1:0]” signal as shown in Figure 3. The pins that we are using are used by Wi-Fi and Bluetooth on-board for their ready signals, however, since we are not actually using the Wi-Fi and Bluetooth in this design, it is safe to access them through our design. Please note that we cannot use these LEDs if we have either the PYNQ or the PetaLinux designs.

image

Once we do this and save the constraints file, we can then generate the bitstream for the design. Then we can export the hardware design so that later on we will import that design to Vitis in order to enable the clock signal as Ultra96v2 does not provide a direct access to clock from the PL side.

3. Blinking the LEDs using Vitis

We can then import the hardware platform that we exported through Vivado and create a hello world application in Vitis. Then, in place of just printing hello world, we can use the following code to blink the LEDs.

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xgpio.h"

#define GPIO_ID XPAR_GPIO_0_DEVICE_ID
#define LED_CHAN 1		/* GPIO Channel */
#define DELAY 100000000	/* 100MHz clock*/


/* Create an instance of the GPIO */
XGpio gpio;

int main()
{
	int status;
	volatile int delay;
    init_platform();

    status = XGpio_Initialize(&gpio, GPIO_ID);
    if (status != XST_SUCCESS)
    	return XST_FAILURE;

    while(1){
    	XGpio_DiscreteWrite(&gpio, LED_CHAN, 0x01);

    	for (delay = 0; delay < DELAY; ++delay);

    	XGpio_DiscreteWrite(&gpio, LED_CHAN, 0x02);

    	for (delay = 0; delay < DELAY; ++delay);
    }

    cleanup_platform();
    return 0;
}

4. Result

We then build the project and then run the application on hardware. Then, we will get the police lights flashing as you can see in the video below.

YouTube: https://youtu.be/J5f8HpWGUiw

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

5. Conclusion

Creating a simple LED flashing design on the Ultra96v2 board using both the PS and PL is both fun and educational. It offers a glimpse into the world of FPGA design and the potential of the Ultra96v2 board. This police light simulation is just the tip of the iceberg. In the next blog, we will again blink LEDs using PL but rather than just using Vivado and Vitis, we will use PYNQ.

  • Sign in to reply
  • rajivbishwokarma
    rajivbishwokarma over 2 years ago in reply to navadeepganeshu

    Thanks! 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • navadeepganeshu
    navadeepganeshu over 2 years ago

    Good start! Nice overview on the end-to-end process.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
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