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

4 Answers 4

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;
7
  • Thanks for the reply Jonathan. I already tried this but unfortunately it only results in hanging of the software. Apr 11, 2015 at 16:00
  • Did you use the axi_gpio module to control your leds? Apr 11, 2015 at 16:04
  • Yes I did, this is the reason for me asking. Normally it should work. Apr 11, 2015 at 18:20
  • I tested the code I gave you, it works (on a microblaze, but still). If the system hangs, it's usually because the bus transfer never returns. Double-check your system, I suggest you use the defines in <xparameters.h> instead of manual address input. Apr 11, 2015 at 18:23
  • I'll try the defines within <xparameters.h>, thanks anyway :) Apr 11, 2015 at 19:00
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.