cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
5,998 Views
Registered: ‎09-16-2018

Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hello all

I have Xilinx Zyngq UlstraScale+ and try to blink LED on this board

I undersantd there are two part for this process

 

(1) Used Vivado (2018.2) to design and implement the HW

     this part I'm got problem.  I try to create the HW from vivado

     then export them including bitstream into SDK for apps development

     but some how I all way false in this part

 

(2) I'm ok with how to create application inside SDK then load the build

     into the board to blinking LEDs

 

the LEDs I try to blink is from manual said PS-side LED DS50, placed

next to the pushbotton, is connected to MIO23 (poin U4.AD19)

OR can blink any LED on the board I don't mind

 

all I need is vivado designed part so I can export hardware to the 

SDK.  

 

how do I get an example or any lab demo how to blink LEDs for

this Zynq UlstraScale+

 

your help is greatly appreciated

 

Best Regard

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Observer
Observer
5,932 Views
Registered: ‎09-16-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hello Savula

 

Thanks for your help, 

Yes I did Add AXI GPIO and interface this port as 8bit-LED

the problem is that in the App/SW in SDK I don't know how to 

map to physical LEDs to this port.  How do accomplish this

 

Here is codes in the SDK to blinking LEDs

 

as you see #define LED 0xC3 // what number equivalent to Zynq UltraScale+ and what LED on the board

 

 

#include <stdio.h>

#include "platform.h"

#include "xparameters.h"

#include "xgpio.h"

#include "xstatus.h"

 

#define GPIO_DEVICE_ID             XPAR_AXI_GPIO_0_DEVICE_ID

#define LED                                    0xC3  <-- what number for Zynq UltraScale board

#define LED_DELAY                         10000000

#define LED_CHANNEL                  1

 

XGpio Gpio;                        // Instantiated GPIO device driver instance

 

int LEDOutput()

{

                volatile int Delay;

                int Status;

                int led = LED;

               

                Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);

               

                if ( Status != XST_SUCCESS ) { return XST_FAILURE; }

               

                //Set direction for the LED output

                XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);

               

                //Infinitive loop to blink LEDs

                while (1) {

                                // write output to the LEDs

                                XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, led);

                                led = ~led;                           /* flip LEDs */

                               

                                // Delay so that LEDs blinking is visible

                                for (Delay = 0; Delay < LED_DELAY; Delay++) {;}

                }

               

                printf("Oop! Never get into here\n\r");

                return XST_SUCCESS;

}

 

int main()

{

                int Status;

               

    init_platform();

    Status = LEDOutput();

   

    if ( Status != XST_SUCCESS) {

                print("GPIO output the the LEDs failed!\n\r");

    }

 

    cleanup_platform();

    return 0;

}

 

 

View solution in original post

0 Kudos
16 Replies
Highlighted
Xilinx Employee
Xilinx Employee
5,949 Views
Registered: ‎10-30-2017

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hi @josephchau77,

 

 

Please follow the Lab 1  in Vivado design suite tutorial.

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_2/ug940-vivado-tutorial-embedded-design.pdf

 

This lab is based on Zynq7000 and you can follow the same steps for Zynq MP too. 

 

don't add the BRAM, just add the AXI GPIO and select the GPIO interface as LEDs.

 

Best Regards,
Srikanth
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

0 Kudos
Highlighted
Observer
Observer
5,933 Views
Registered: ‎09-16-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hello Savula

 

Thanks for your help, 

Yes I did Add AXI GPIO and interface this port as 8bit-LED

the problem is that in the App/SW in SDK I don't know how to 

map to physical LEDs to this port.  How do accomplish this

 

Here is codes in the SDK to blinking LEDs

 

as you see #define LED 0xC3 // what number equivalent to Zynq UltraScale+ and what LED on the board

 

 

#include <stdio.h>

#include "platform.h"

#include "xparameters.h"

#include "xgpio.h"

#include "xstatus.h"

 

#define GPIO_DEVICE_ID             XPAR_AXI_GPIO_0_DEVICE_ID

#define LED                                    0xC3  <-- what number for Zynq UltraScale board

#define LED_DELAY                         10000000

#define LED_CHANNEL                  1

 

XGpio Gpio;                        // Instantiated GPIO device driver instance

 

int LEDOutput()

{

                volatile int Delay;

                int Status;

                int led = LED;

               

                Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);

               

                if ( Status != XST_SUCCESS ) { return XST_FAILURE; }

               

                //Set direction for the LED output

                XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);

               

                //Infinitive loop to blink LEDs

                while (1) {

                                // write output to the LEDs

                                XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, led);

                                led = ~led;                           /* flip LEDs */

                               

                                // Delay so that LEDs blinking is visible

                                for (Delay = 0; Delay < LED_DELAY; Delay++) {;}

                }

               

                printf("Oop! Never get into here\n\r");

                return XST_SUCCESS;

}

 

int main()

{

                int Status;

               

    init_platform();

    Status = LEDOutput();

   

    if ( Status != XST_SUCCESS) {

                print("GPIO output the the LEDs failed!\n\r");

    }

 

    cleanup_platform();

    return 0;

}

 

 

View solution in original post

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
5,918 Views
Registered: ‎10-30-2017

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hi @josephchau77,

 

You can map the on board leds to port by writing a constraint file (.xdc) in vivado. If you are using Xilinx  evaluation board (if you select the board while creating the project) then no need to write this constraint file, why because all the information is already available in board files. when you select LEDs then automatically they are mapped to physical LEDs. you don't need to map anything. just run your code from the SDK.

 

Best Regards,
Srikanth
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

0 Kudos
Highlighted
Observer
Observer
5,902 Views
Registered: ‎09-16-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Thank Savula

 

If I already select the board then there is no way I can blinking a particular 

LED on the board (i.e. for example LED DS50).  If we can then how do

I do that.

 

Right now the 8-LED is blinking

 

Best Regards

Joseph

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
5,897 Views
Registered: ‎10-30-2017

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

HI @josephchau77,

 

if the MIO pin connected to LED as configured as the GPIO in Vivado the you can control it from SDK. if the MIO is not configured as GPIO then it is not possible to control it.

 

If you want control LED on specific board, first you should confirm that whether the LED is connected to PS or PL. if it is connected to PS then make sure that MIO should be configured as GPIO and in this case no need of writing the constraint. 

 

in case of LED is connected to PL side then take AXI GPIO instant and write constraint as per the LED pins in vivado. 

 

Best Regards,
Srikanth
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

 

 

 

0 Kudos
Highlighted
Observer
Observer
5,893 Views
Registered: ‎09-16-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Thank Savula,

 

If you want control LED on specific board, first you should confirm that whether the LED is connected to PS or PL. if it is connected to PS then make sure that MIO should be configured as GPIO and in this case no need of writing the constraint. 

 

If I want to control LED (i.e. DS50) that is connect to PS then how do I config MIO as GPIO please help on this part

I intend to blink LED connect to PS, and run on either APU or RPU.

 

Best Regards

joe chau

 

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
5,886 Views
Registered: ‎10-30-2017

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hi @josephchau77,

 

sure, please follow the below.  i.e. for example LED DS50

if we see the schematic of zcu102 board the LED DS50 is connected to MIO23. So we should configure MIO23 as GPIO.

 

gpio.PNG

 

then export it to hardware and run the application from the SDK.

 

Best Regards,
Srikanth
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

 

0 Kudos
Highlighted
Observer
Observer
5,880 Views
Registered: ‎09-16-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

 

Thanks a lot Savula,

 

FYI: this is first time I'm learning Zynq/UlstraScale+ and try to get experience on this boart

        as a beginner .

 

(1) from Vivado how do I get to the Config table you just post, so can set MIO23 (LED DS50) as GPIO

     for PS.

 

(2) I try to run both application on both processor: APU and RPU

      (a) APU (4-core) blinking LED via PL/GPIO on CORE-0, with the following building file

            * A53-0_led.elf, A53-0-led-FSBL.elf, and bitstream file export from Vivado

      (b) RPU (2-core) blinking LED DS50 via PS (you mention how to config above) generated the following files

            * R5-0-led.elf, R5-0-led-FSBL.elf, bitstream is the same as above.

 

      How can I create a bootimage (BOOT.bin) so when I flash via QSPi (SW6 = 0100) and run, both application

      will run simultaneously on both APU and RPU.

 

      Here is list of order when I created bootimage (select ADD from the menu)

                A53-0-led-FSBL.elf

                bitstream (export from vivado)

                A53-0-led.elf

                R5-0-led-FSBL.elf     <--- I suspect wrong right here

                bitstream                   <-- I suspect NO NEED since redo again from above

                R5-0-led.elf

 

Thank savula

joe chau

     

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
5,865 Views
Registered: ‎10-30-2017

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hi @josephchau77,

 

add the Zynq UltraScale+ IP in Block design and Double-click the Zynq UltraScale+ IP Block, it will open the re-customize IP and select the GPIOs.

 

Create a Boot image with below one

A53-0-led-FSBL.elf

pmu_firmware.elf

bitstream 

R5-0-led.elf

A53-0-led.elf

 

for PMU_firmware, Please create a new application in SDK targeting PMU processor  (PSU_PMU_0) and select the template as ZynqMP firmware.

 

Best Regards,
Srikanth
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

0 Kudos
Highlighted
Observer
Observer
5,536 Views
Registered: ‎09-16-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Thanks for you response Savula

 

(1) Here is question for config PS/GPIO, follow your suggestion 

     double click Zynq UltraScale+, click GPIO it show as in attach

    picture P1.jpg.  From P1 you see by default the first option is empty

    GPIO EMO.  The last two option GPIO0 MIO - MIO 0..25, GPIO1 MIO 26.51

 

    do I need to set GPIO EMIO = 23, as show in attach picture P2

    please confirm.

 

(2) this regarding to create boot image from SDK then run on the host windows

     I follow exactly your suggestion:

  

     PMU_firmware, create a new application in SDK targeting PMU processor  (PSU_PMU_0) and select

     the template as ZynqMP firmware THIS GIVE ME: PMU_firmware.elf.

 

     Create boot image by order as followed (with Architecture = Zynq MP)

     A53-0-led-FSBL.elf:     

              Partition type = bootloader (by default)

              Destination Device: PS       Destination CPU: A53 x64

     pmu_firmware.elf:

             Partition type = datafile   --> SHOULD I CHANGE to pmu (loaded by bootrom)

              Destination Device: PS       Destination CPU: A53_0

     bitstream

            Partition type = datafile   

             Destination Device: PL       Destination CPU: A53_0

     R5-0-led.elf

             Partition type = datafile   

              Destination Device: PS       Destination CPU: R5_0

     A53-0-led.elf

             Partition type = datafile   

              Destination Device: PS       Destination CPU: A53_0

 

your help is greatly appreciate

 

Best Regards

joe chau

 

P1.jpg
P2.jpg
0 Kudos
Highlighted
Visitor
Visitor
4,842 Views
Registered: ‎02-13-2019

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hello all

I have similar problems. I work with part  ad9361zc7035. I don't know which MIO connects to my led (ex D4). Where can I find the schematic?

Thanks

0 Kudos
Highlighted
Contributor
Contributor
4,807 Views
Registered: ‎11-21-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hi,

I want to do the same with the eval board ZCU111 (Ultrascale+ RFSoC), 

I want to blink leds in some specific parts of project but I don't know why I am not able to find the zynq IP in vivado.

 Capture.JPG

I can have the zynq Ultrascale+ RF data  converter IP but I can't find where design with gpio with this one.

Does someone have an idea?

Best regard,

0 Kudos
Highlighted
Contributor
Contributor
4,788 Views
Registered: ‎11-21-2018

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hi,

I think you misunderstand : 0xC3 is hexadecimal number for 1100 0011, If you want a specific led just change this one and delete this line:  

led = ~led;                           /* flip LEDs */

for example if you want the first led : 0x01 the second 0x02 etc.. if you want all led 0xFF .

If you want to change one led a time try this code:

#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "xgpio.h"
#include "xstatus.h"

#define GPIO_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID
#define LED 0x01
#define LED_DELAY 100000000
#define LED_CHANNEL 1

XGpio Gpio; // Instantiated GPIO device driver instance

int LEDOutput()

{
volatile int Delay;
int Status;
int led = LED;
Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
if ( Status != XST_SUCCESS ) { return XST_FAILURE; }

//Set direction for the LED output
XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);

//Infinitive loop to blink LEDs
while (1) {
while(led<=128){
// write output to the LEDs
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, led);
// Delay so that LEDs blinking is visible
led = led<<1;
for (Delay = 0; Delay < LED_DELAY; Delay++) {;}
}
led=LED;

}
printf("Oop! Never get into here\n\r");
return XST_SUCCESS;

}

 

int main()

{

int Status;
init_platform();
Status = LEDOutput();
if ( Status != XST_SUCCESS) {
print("GPIO output the the LEDs failed!\n\r");

}
cleanup_platform();
return 0;

}

 

0 Kudos
Highlighted
Visitor
Visitor
4,750 Views
Registered: ‎02-13-2019

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Thanks for help. But I can't blink any LEDs. I don't think that 0xC3 is only hexadecimal number.

Here is codes in the SDK to blinking LED with a button

As you see

#define OUTPUT_PIN    7             /*MIO7,  pin connected  to LED */

#define INPUT_PIN        50           /*MIO50, pin connected to button */

Why 7 and 50? I don't know what the MIO pin conected to the LED.

 

//            header files

#include "xparameters.h"

#include "xgpiops.h"

#include "xstatus.h"

#include <xil_printf.h>

//            defines

#define GPIO_DEVICE_ID   XPAR_XGPIOPS_0_DEVICE_ID

#define OUTPUT_PIN    7             /*MIO7,  pin connected  to LED */

#define INPUT_PIN        50           /*MIO50, pin connected to button */

#define printf xil_printf   /* Smalller foot-print printf */

//            global    variables

XGpioPs GpioPs;

/*           The driver  instance for GPIO Device.     */

XGpioPs_Config *ConfigPtr;

//            main      function

int main(void)

{

                int Status;

                //            initialize                the         GpioPs  driver.

                ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);

                Status   = XGpioPs_CfgInitialize(&GpioPs, ConfigPtr, ConfigPtr->BaseAddr);

                if (Status != XST_SUCCESS)          { return XST_FAILURE;   }

//            configure             the         LED         pin          as            output

                XGpioPs_SetDirectionPin(&GpioPs,        OUTPUT_PIN,   1);

                XGpioPs_SetOutputEnablePin(&GpioPs,              OUTPUT_PIN,   1);

//            Set         the         direction              for          the         specified              pin          to            be           input.

XGpioPs_SetDirectionPin(&GpioPs,        INPUT_PIN,        0);

while(1)

{

//            if input  is read   as HIGH, button                is not  pressed

u8 data =             XGpioPs_ReadPin(&GpioPs,       INPUT_PIN);

XGpioPs_WritePin(&GpioPs, OUTPUT_PIN, !data);

//LED     MIO7     ON  when data=0, OFF when      data=1

}

return XST_SUCCESS;

}

0 Kudos
Highlighted
3,594 Views
Registered: ‎05-23-2019

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Thanks a million to you for this code. It was a really big help for me. God bless you.

0 Kudos
Highlighted
Observer
Observer
2,982 Views
Registered: ‎02-01-2019

Re: Blinking LED with Xilinx Zynq Ultrascale+

Jump to solution

Hi,

I have same problem. I have ZCU102 board Rev 1.1.   I did the axi gpio design with leds8bit, export sdk. When I run System Debugger with this code, no leds blink. I think I have problem with my JTAG configuration. SW6 is on,on,on,on (JTAG mode). Is there any other configuration to apply ? Is there any reported problem with this revision of the board ? I did same design with ZC702 by  using this C code, it worked. We use Vivado 2018.3 and 2017.4. No result with both.

Best Regards.

0 Kudos