• 0

Arty A7 basic IO problem


Question

Hi,

On my Arty A7 board i have the hello world running with Microblaze and UART.
I added from the board tab the 4 buttons then i added the 4 LEDs.
I'm using 2020.1, and by default it combined the AXI GPIO so there is a dual channel GPIO where both the leds and the buttons are connected.
My problem is, that in Vitis the generated IO example code uses the same port, and only the buttons work...

the device gets configured as such in the code:
#define GPIO_OUTPUT_DEVICE_ID    XPAR_GPIO_0_DEVICE_ID
#define GPIO_INPUT_DEVICE_ID    XPAR_GPIO_0_DEVICE_ID

In xparameters.h i found this:

/* Definitions for driver GPIO */
#define XPAR_XGPIO_NUM_INSTANCES 1

/* Definitions for peripheral AXI_GPIO_0 */
#define XPAR_AXI_GPIO_0_BASEADDR 0x40000000
#define XPAR_AXI_GPIO_0_HIGHADDR 0x4000FFFF
#define XPAR_AXI_GPIO_0_DEVICE_ID 0
#define XPAR_AXI_GPIO_0_INTERRUPT_PRESENT 0
#define XPAR_AXI_GPIO_0_IS_DUAL 1

/* Canonical definitions for peripheral AXI_GPIO_0 */
#define XPAR_GPIO_0_BASEADDR 0x40000000
#define XPAR_GPIO_0_HIGHADDR 0x4000FFFF
#define XPAR_GPIO_0_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID
#define XPAR_GPIO_0_INTERRUPT_PRESENT 0
#define XPAR_GPIO_0_IS_DUAL 1

The wizard creates two functions:
GpioOutputExample( GPIO_OUTPUT_DEVICE_ID, GPIO_BITWIDTH);
GpioInputExample(XPAR_AXI_GPIO_0_DEVICE_ID, &DataRead);

input example works (buttons), but output does not (leds)

Any help is appreciated!

Csaba

io.jpg

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

The GPIO API uses channels, #1 for push buttons and #2 for LEDS.  For example:

static XGpio gPIOBoardLEDAndPushbuttonss;

...

int rc = XGpio_Initialize(&gPIOBoardLEDAndPushbuttonss,0);

notice the API has 3 parameters, the GPIO handle, which channel 1 for Push buttons set data direction

XGpio_SetDataDirection(&gPIOBoardLEDAndPushbuttonss, 1, 1);

XGpio_SetDataDirection(&gPIOBoardLEDAndPushbuttonss, 2, 0);  set output for LEDs

XGpio_DiscreteWrite(&gPIOBoardLEDAndPushbuttonss, 2, 0x7);

 

Link to post
Share on other sites
  • 0

It might help someone, so i note that if the leds and buttons are connected to separate GPIO blocks, then Vitis generates the correct code for both.
Based on the help above i managed to make it work from one dual GPIO.

Edited by Edocecrous
typo
Link to post
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