Jump to content
  • 0

Reading and witing the PL GPIOs using Zynq


dpaul

Question

Hello,

I have a Z7-10 board. I am writing software for the Zynq, which will access 8 GPIO pins via the PL (using the AXI GPIO IP). These will be 4 each on-board LEDs LD0-LD3 (to be configured as output) and DIP switches SW0-SW3(to be configured as input). The BD is shown below. The offset and high address are shown below in the SS.

xgpiops.png.afb3cb05a2652da2550618244ab49d83.png

My target is to read the status of the 4x slide switches and write those values back to the LEDs in order.

So to achieve that, after initializing the GPIO, I have also set the direction of the bits as shown in the following 2 lines.

Status = XGpio_CfgInitialize(&my_Gpio, GPIO_Config, GPIO_Config -> BaseAddress);

XGpio_SetDataDirection(&my_Gpio, 1, 15); // Only the 4 LSB bits are inputs(4x slide switches), so 1's

 

Now all I have to do is to read the switch status and write them back to the LEDs inside a while loop. However I am not sure how to use the XGpio_ReadReg() or XGpio_WriteReg().

SDK tells me the to use XGpio_*Reg(BaseAddress, RegOffset). But what would be my BaseAddress, RegOffset?

Will it be as shown in the Address Editor, i.e. BaseAddress = 0x4120_0000 and RegOffset = 0x00000000?

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Alternatively, when using the Xilinx Standalone OS you can just access gpio and other hardware in C using pointers instead of the provided library api, just as you might for a uC application without an OS. Just be aware that even the Z7010 ARM cores are fast enough to cause bus faults for some AXI interfaces, like the Xilinx AXI-GPIO IP, so you can't necessarily poll GPIO at the highest rates. Still, if you like using AXI BRAM as an interface between your PL and ARM cores, it make for a more consistent coding style. Don't try this with a linux or RTOS OS.

Edited by zygot
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...