0 Replies Latest reply on Feb 26, 2019 10:00 AM by alphatozeta@yahoo.com

    MiniZed LED Red / Green Control

    alphatozeta@yahoo.com

      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;

      }