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

user3488736
  • 109
  • 1
  • 3
  • 13

4 Answers4

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;
Jonathan Drolet
  • 3,318
  • 1
  • 12
  • 23
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.

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);
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

Community
  • 1
  • 1
Rajat Sewal
  • 117
  • 1
  • 3