element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
MicroZed Hardware Design MicroZed software push-button interrupt
  • 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 Verified Answer
  • Replies 4 replies
  • Subscribers 310 subscribers
  • Views 810 views
  • Users 0 members are here
Related

MicroZed software push-button interrupt

ewasserm
ewasserm over 7 years ago
Hello!
I'm using the MicroZed 7010 board, with Xilinx SDK 2015.4.
I'm trying to write a simple C code that will flash the LED when a push-button interrupt occurs.
The status readings all report success, but when I press the button, nothing happens... What am I missing?
BTW, I saw the famous Adam Taylor’s MicroZed Chronicles blog:
https://forums.xilinx.com/t5/Xcell-Daily-Blog/More-About-MicroZed-Interrupts-Adam-Taylor-s-MicroZed-Chronicles/ba-p/398357
I have downloaded and tried his code - it doesn't work either!
I would be happy to get help with this. Thank you all!
my code goes as follows:
 
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "platform.h"
#include "xgpio.h"
#include "xgpiops.h"
#include "xparameters.h"
#include "xstatus.h"
#include "Xscugic.h"
#include "xil_exception.h"
 
static XGpioPs my_Gpio;
static XScuGic my_Gic;
static void USR_button_ISR(void *CallBackRef);
 
int main()
{
  init_platform();
  XGpioPs_Config *GPIO_Config;
  GPIO_Config = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
  int status;
  status = XGpioPs_CfgInitialize(&my_Gpio, GPIO_Config, GPIO_Config->BaseAddr);
  if (status == XST_SUCCESS)
printf("XGpioPs configuration successful! \n\r");
  else
printf("XGpioPs configuration failed! \n\r");
  XGpioPs_SetDirectionPin(&my_Gpio, 47, 1); // board LED, output
  XGpioPs_SetOutputEnablePin(&my_Gpio, 47, 1);
  XGpioPs_SetDirectionPin(&my_Gpio, 51, 0); // USR button, input
  XScuGic_Config *Gic_Config;
  Gic_Config = XScuGic_LookupConfig(XPAR_PS7_SCUGIC_0_DEVICE_ID);
  status = XScuGic_CfgInitialize(&my_Gic, Gic_Config, Gic_Config->CpuBaseAddress);
  if (status == XST_SUCCESS)
    printf("GIC configuration successful! \n\r");
    else
    printf("GIC configuration failed! \n\r");
  Xil_ExceptionInit();
  Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XScuGic_InterruptHandler, &my_Gic);
  status = XScuGic_Connect(&my_Gic, XPS_GPIO_INT_ID, (Xil_ExceptionHandler)USR_button_ISR, (void *)&my_Gic);
  if (status == XST_SUCCESS)
  printf("Interrupt handler connection successful! \n\r");
  else
  printf("Interrupt handler connection failed! \n\r");
  XGpioPs_SetIntrTypePin(&my_Gpio, 51, XGPIOPS_IRQ_TYPE_EDGE_RISING);
  //XGpioPs_SetCallbackHandler(&my_Gpio, (void *)&my_Gpio, (XGpioPs_Handler)USR_button_ISR);
  XGpioPs_IntrEnablePin(&my_Gpio, 51);
  XScuGic_Enable(&my_Gic, XPS_GPIO_INT_ID);
  Xil_ExceptionEnable();
  printf("waiting...\n");
  while (1)
  {
  }
 
  cleanup_platform();
  return 0;
}
 
static void USR_button_ISR(void *CallBackReff)
{
  XGpioPs_WritePin(&my_Gpio, 47, 1);
  sleep(5);
  XGpioPs_WritePin(&my_Gpio, 47, 0);
}
  • Sign in to reply
  • Cancel
  • jafoste4
    0 jafoste4 over 7 years ago

    Hi,

    In your vivado hardware design did you enable MIO 47(ps led D3)?

    --Josh

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ewasserm
    0 ewasserm over 7 years ago in reply to jafoste4

    Hi, yes I did - if you are referring to this option is the PS7 IP configuration window:

     image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ewasserm
    0 ewasserm over 7 years ago in reply to ewasserm

    Zynq PS block configuration-> MIO configuration -> I/O Peripherals -> GPIO -> enable GPIO MIO

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ewasserm
    0 ewasserm over 7 years ago
    The problem may have been an "unclean" interrupt flag, so I have added the command
    XGpioPs_IntrClearPin(&my_Gpio, 51);
    in USR_button_ISR and during the setup in the main program.
    Thanks for your help!
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject 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