element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Achievement Levels
    • Benefits of Membership
    • Feedback and Support
    • Members Area
    • Personal Blogs
    • What's New on element14
  • Learn
    Learn
    • eBooks
    • Learning Center
    • Learning Groups
    • STEM Academy
    • Webinars, Training and Events
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Arduino Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Project Groups
    • Raspberry Pi Projects
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Or 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
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
MiniZed Hardware Design MiniZed LED Red / Green Control
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Avnet Boards Forums requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 0 replies
  • Subscribers 173 subscribers
  • Views 143 views
  • Users 0 members are here
Related

MiniZed LED Red / Green Control

alphatozeta@yahoo.com
alphatozeta@yahoo.com over 4 years ago

I cloned and went through the example "Prebuilt Platforms Using Hardware Definition Files (HDFs)" https://github.com/Avnet/hdl/tree/mz_petalinux_2018_2 .

I can get the Hello World printf() statements to work and have been trying to blink the Red/Green LED's. I've tried to follow the only examples I can find but none of them are specific for the minized.

The examples I can find write directly to a pin number and use XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID); to setup the I/O. I think I should be using  XPAR_AXI_GPIO_0_DEVICE_ID.

Nothing works and I have no idea what to put for the pin number. My code is below.

Help please!

 

//------------------------------------------------------------------------------------------------------------------------------

#include <stdio.h>

#include <math.h>

#include "platform.h"

#include "xil_printf.h"

#include "xgpiops.h"

////#include "xparameters_ps.h"

#include "xparameters.h"

 

int main()

{

    XGpioPs_Config *GPIO_Config;

    XGpioPs my_Gpio;

    int Status;

    int LED_ONOFF = 0;

    int i,j;

    int portpin = 0;

    float raddeg,deg,num;

    init_platform();

 

    print("\n\rHello World\n\r");

   

    // Port Setup

     //GPIO_Config = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);

    GPIO_Config = XGpioPs_LookupConfig(XPAR_AXI_GPIO_0_DEVICE_ID);

    Status = XGpioPs_CfgInitialize(&my_Gpio, GPIO_Config,GPIO_Config->BaseAddr);

    XGpioPs_SetDirection(&my_Gpio,portpin,1);        //Set Pin Direction. (1 == output)

    XGpioPs_SetOutputEnablePin(&my_Gpio,portpin,1);    //Enable output pin

 

    printf("GPIO Setup Completed\n\r");

 

   //Blink the LED 5 times and delay blink by printing to screen.

    for(j=0;j<5;j++)

    {

        for (i=0;i<=4000;i++)

        {

           printf("LED=%d\r",LED_ONOFF);

        }

        printf("\nLEDChange\n\r");

        if(LED_ONOFF == 1)

            {

            LED_ONOFF = 0;

            printf("LED is OFF\n\r");

            }

        else

            {

            LED_ONOFF = 1;

            printf("LED is ON\n\r");

            }

 

        XGpioPs_WritePin(&my_Gpio,portpin,LED_ONOFF);

    }

 

cleanup_platform();

return 0;

}

  • Sign in to reply
  • 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 © 2023 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