element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development AXI_GPIO Block width
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 5 replies
  • Subscribers 328 subscribers
  • Views 372 views
  • Users 0 members are here
Related

AXI_GPIO Block width

Former Member
Former Member over 11 years ago

Hi everyone,
i'm currently working on a zedboard and have been able to achieve the following steps:

reading and writing to any MIO
reading and writing to any IO routed by an AXI_GPIO block

there's still one thing i am not getting right:

for instance i would like to read the 8 different switches.
I create a top and a bitstream with an AXI GPIO BLOCK with a width set to 8.
the .mhs then created looks like

BEGIN axi_gpio
PARAMETER INSTANCE = axi_gpio_0
PARAMETER HW_VER = 1.01.b
PARAMETER C_GPIO_WIDTH = 8
PARAMETER C_BASEADDR = 0x41200000
PARAMETER C_HIGHADDR = 0x4120ffff
BUS_INTERFACE S_AXI = axi_interconnect_1
PORT S_AXI_ACLK = processing_system7_0_FCLK_CLK0
PORT GPIO_IO = axi_gpio_0_GPIO_IO
END

then i suppose my ucf file will be like

NET axi_gpio_0_GPIO_IO[0] ...
.
.
NET axi_gpio_O_GPIO_IO[7] ...

and finally on the software C:

XGpio mySw;
XGpio Init(&mySw)

but then i am only able to read/write to the First (least significant bit) switch.
How do you handle the fact of having a bunch of GPIO into an AXI GPIO?

The only answer i found yet was to create an AXI GPIO BLOCK for every GPIO
which means that my ucf is now like
NET axi_gpio_0_GPIO_IO ...
.
NET axi_gpio_j_GPIO_IO ..
.
NET axi_gpio_n_GPIO_IO ...

and in the software i declare a XGpio for every single GPIO.
Which is pretty heavy and i'm sure there's one thing i'm missing, one way of doing it better.

Thanks for your advices

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Looks like ur hardware design is fine, but take a closer look on XGpio structure:

    /**
    * The XGpio driver instance data. The user is required to allocate a
    * variable of this type for every GPIO device in the system. A pointer
    * to a variable of this type is then passed to the driver API functions.
    */
    typedef struct {
    tu32 BaseAddress;t/* Device base address */
    tu32 IsReady;tt/* Device is initialized and ready */
    tint InterruptPresent;t/* Are interrupts supported in h/w */
    tint IsDual;tt/* Are 2 channels supported in h/w */
    } XGpio;

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    thanks for your quick answer,
    i find it rather hard having documentations,
    i barely found two examples (the tutorial & zynqgeek on github ).
    i guess you found this inside the #xilinx includes

    i should have a closer look at the different process like Gpio Initialize, Gpio write and read, i'll check this tomorow.

    So if my h/w specification is right (the one with a single axi_gpio_O_IO but with the [7:0]
    you suggest that the solution is in the u32 BaseAdress? linked to the axi_gpio (.mhs)
    PARAMETER C_BASEADDR = 0x41200000
    PARAMETER C_HIGHADDR = 0x4120ffff

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    You also have to set directions - I don't know if you did already.
    Post the all relevant code.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    thanks for your help
    i'll give you everything and will try to be the most accurate.

    i have an axi gpio block for my 5 buttons
    and an axi gpio block for my 8 LEDS
    this is my .mhs

    PORT axi_gpio_0_GPIO_IO_pin = axi_gpio_0_GPIO_IO, DIR = IO, VEC = [7:0]     -- for the leds
    PORT axi_gpio_1_GPIO_IO_pin = axi_gpio_1_GPIO_IO, DIR = IO, VEC = [4:0]     -- the push buttns
    PORT processing_system7_0_GPIO_pin = processing_system7_0_GPIO, DIR = IO, VEC = [7:0]


    BEGIN axi_gpio
    PARAMETER INSTANCE = axi_gpio_0
    PARAMETER HW_VER = 1.01.b
    PARAMETER C_GPIO_WIDTH = 8
    PARAMETER C_BASEADDR = 0x41200000
    PARAMETER C_HIGHADDR = 0x4120ffff
    BUS_INTERFACE S_AXI = axi_interconnect_1
    PORT S_AXI_ACLK = processing_system7_0_FCLK_CLK0
    PORT GPIO_IO = axi_gpio_0_GPIO_IO
    END


    BEGIN axi_gpio
    PARAMETER INSTANCE = axi_gpio_1
    PARAMETER HW_VER = 1.01.b
    PARAMETER C_GPIO_WIDTH = 5
    PARAMETER C_ALL_INPUTS = 1
    PARAMETER C_BASEADDR = 0x41240000
    PARAMETER C_HIGHADDR = 0x4124ffff
    BUS_INTERFACE S_AXI = axi_interconnect_1
    PORT S_AXI_ACLK = processing_system7_0_FCLK_CLK0
    PORT GPIO_IO = axi_gpio_1_GPIO_IO
    END


    this is my constraint file .ucf
    //AXI GPIO LEDS [7:0] LVCMOS25 pr les LEDS
    NET axi_gpio_0_GPIO_IO_pin[0] IOSTANDARD=LVCMOS33 | LOC = T22 ;
    NET axi_gpio_0_GPIO_IO_pin[1] IOSTANDARD=LVCMOS33 | LOC = T21 ;
    NET axi_gpio_0_GPIO_IO_pin[2] IOSTANDARD=LVCMOS33 | LOC = U22 ;
    NET axi_gpio_0_GPIO_IO_pin[3] IOSTANDARD=LVCMOS33 | LOC = U21 ;
    NET axi_gpio_0_GPIO_IO_pin[4] IOSTANDARD=LVCMOS33 | LOC = V22 ;
    NET axi_gpio_0_GPIO_IO_pin[5] IOSTANDARD=LVCMOS33 | LOC = W22 ;
    NET axi_gpio_0_GPIO_IO_pin[6] IOSTANDARD=LVCMOS33 | LOC = U19 ;
    NET axi_gpio_0_GPIO_IO_pin[7] IOSTANDARD=LVCMOS33 | LOC = U14 ;

    //AXI GPIO PUSH BTNS [4:0] LVCMOS 25 pr les btns
    NET axi_gpio_1_GPIO_IO_pin[0] IOSTANDARD=LVCMOS25 | LOC = T18;
    NET axi_gpio_1_GPIO_IO_pin[1] IOSTANDARD=LVCMOS25 | LOC = R18;
    NET axi_gpio_1_GPIO_IO_pin[2] IOSTANDARD=LVCMOS25 | LOC = R16;
    NET axi_gpio_1_GPIO_IO_pin[3] IOSTANDARD=LVCMOS25 | LOC = N15;
    NET axi_gpio_1_GPIO_IO_pin[4] IOSTANDARD=LVCMOS25 | LOC = P16;



    this is my soft application
    inside a main

    XGpio Gpio_Led;
    XGpio Gpio_Btn;

    //AXI GPIO LED INIT
        xStatus = XGpio_Initialize(&Gpio_Led,XPAR_AXI_GPIO_0_DEVICE_ID);
        if (xStatus != XST_SUCCESS)
        {
        tprint("Fail init LED AXI GPIOr
    ");
        treturn XST_FAILURE;
        }

        XGpio_SetDataDirection(&Gpio_Led,CHANNEL_1,OUTPUT);

        //AXI GPIO BTN INIT
        xStatus = XGpio_Initialize(&Gpio_Btn,XPAR_AXI_GPIO_1_DEVICE_ID);
        if (xStatus != XST_SUCCESS)
        {
          tprint("Fail init LED AXI GPIOr
    ");
        treturn XST_FAILURE;
        }

    then a writing process is like
    //write LED AXI
    XGpio_DiscreteWrite(&Gpio_Led, CHANNEL_1, 1);

    a reading process of the axi GPIO BTNS is like
    pushbuttons = XGpio_DiscreteRead(&Gpio_Btn, CHANNEL_1);

    which only writes and reads the LSB base address, so the only first LED and first BTNS

    first of all i write XGpio_Initialize(&Gpio_Led,XPAR_AXI_GPIO_0_DEVICE_ID);
    which if i'm right referes to the .mhs or the .ucf axi_gpio_0 which has a width of 8 and which describes my LEDS.
    same for the 5 pushbuttons.

    so it may come from the XPAR_AXI_GPIO
    it may also come from a wrong use of the writing and reading process maybe on the CHANNEL side.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    for ppl interested in
    the correct nesting of pins coming from a vector is
    NET ... pin_IO<i> and not [i] as i used to write

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube