Use of Xil_Out32 in Xilinx SDK

user3488736 picture user3488736 · Apr 11, 2015 · Viewed 11.6k times · Source

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

Answer

Jonathan Drolet picture Jonathan Drolet · Apr 11, 2015

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;