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
Connected Cloud Challenge
  • Challenges & Projects
  • Design Challenges
  • Connected Cloud Challenge
  • More
  • Cancel
Connected Cloud Challenge
Blog #6 GPIO interrupt
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: wanfp97
  • Date Created: 8 May 2020 3:04 AM Date Created
  • Views 1425 views
  • Likes 2 likes
  • Comments 0 comments
  • cypress
  • gpio:
Related
Recommended

#6 GPIO interrupt

wanfp97
wanfp97
8 May 2020

In my previous blog post #5 GPIO read and write , I have faced an issue where my servo is not operating as I want it to. I revised my coding and found out that the problem is probably due to the compare value of the tcpwm1 keep toggling as I'm keep polling the status of the button GPIO input pin.

 

While I'm finding the solution for this issue, I found this example code:

image

A GPIO Interrupt might be the solution for my problem.

 

I created the GPIO_Interrupt Starter application and read through the Readme.md file as well as the code in the main.c to have a brief idea of how will it works.

I then summarized up some of the function that are useful for implementing GPIO interrupt.

    /* Configure GPIO interrupt */
    cyhal_gpio_register_callback(CYBSP_USER_BTN, 
                                 gpio_interrupt_handler, NULL);
    cyhal_gpio_enable_event(CYBSP_USER_BTN, CYHAL_GPIO_IRQ_FALL, 
                                 GPIO_INTERRUPT_PRIORITY, true);

These two function are both new to me, so I will need to find out how will the functions work.

image

I found out that in the Quick Panel under Documentation, there is a documentation for Hardware Abstraction Layer (HAL), since both the functions start with cyhal, there is a great chance that they are included in that documentation.

image

Clicking the link brings me to this documentation page of Cypress Hardware Abstraction Layer.

The interface is similar to the PDL documentation which I have deal with in the previous blog post.

image

Searching the function in the search box bring me to this page.

To summarize things, for cyhal_gpio_register_callback() function:

the 1st argument will be the pin used for the interrupt,

the second argument will be the event_handler,

the third argument can be input NULL.

image

For cyhal_gpio_enable_event() function:

the first argument will be the pin used for the interrupt,

the second argument will be the GPIO event,

the third argument will be interrupt priority, etc.: 1u, 2u, 3u... and so-on.

the forth argument should be true if you want to enable the interrupt.

 

For the second argument, the GPIO event can be choose from the below case:

image

After learning how to utilize the GPIO interrupt, I will try to resolve the problem of the abnormal behavior of the servo in my next blog post

 

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