Use of Xil_Out32 in Xilinx SDK

2

In Vivado I succesfully made a simple blockdiagram to control the LEDs of my Zybo board. I can observe that the offset address for my LEDs is: 0x4120 0000 and the High Address is 0x4120 FFFF. Now when I go to the SDK:

#include <xil_printf.h>
#include <xil_types.h>
#include "platform.h"
#include "xgpio_l.h"

volatile u32 *LED_DATA = (u32 *) 0x41200000 ;   
int main()
{

    init_platform();

    xil_printf(" Writing to LEDs:   \n\r");
    Xil_Out32((&LED_DATA) + (0x00)  , 0xFFFFFFFF);     //All LEDs ON

    cleanup_platform();
    return 0;
}

I programmed the FPGA and run the above code. But still no success whatsoever. Could someone point out my errors?

Thanks in advance

fpga
xilinx
zynq
vivado
asked on Stack Overflow Apr 11, 2015 by user3488736

4 Answers

0

Your mistake is to use &LED_DATA, which return the address of the pointer LED_DATA, not 0x41200000 as I think you expect.

Try

Xil_out32(0x41200000, 0xFFFFFFFF);

or

*LED_DATA = 0xFFFFFFFF;
answered on Stack Overflow Apr 11, 2015 by Jonathan Drolet
0

try

#define ADDR 0x41200000 // write this before main() function.

Then you have to add the following line within main function.

Xil_Out32(ADDR + 0x00000000)  , 0xFFFFFFFF);     //All LEDs ON

This should work.

answered on Stack Overflow May 9, 2015 by (unknown user)
0

This work

#define ADDRESS_GPIO_0   0x41200000     // vivado block diagram address editor

XGpioPs_Config * ConfigPtr1 = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
XGpioPs_CfgInitialize(&Gpio1, ConfigPtr1, ADDRESS_GPIO_0);
XGpioPs_SetDirection(&Gpio1, XGPIOPS_BANK0, 0x0F);
XGpioPs_Write(&Gpio1, XGPIOPS_BANK0, 0x0F);
answered on Stack Overflow Dec 13, 2017 by Chris PnD
0

Thank you for this post. It helped me resolve a compile issue in sdk. The issue was that the line below would not compile.

xil_printf("Wrote: 0x%08x \n\r", *(baseaddr_p+0));

I added this and it worked:

include "xil_printf.h"

Thanks so much Rajat Sewal

answered on Stack Overflow Oct 4, 2019 by Rajat Sewal

User contributions licensed under CC BY-SA 3.0