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
Think ON Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Think ON Design Challenge
  • More
  • Cancel
Think ON Design Challenge
Forum Interrupt on PIN_GIO_SPARE
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 7 replies
  • Subscribers 4 subscribers
  • Views 1448 views
  • Users 0 members are here
Related

Interrupt on PIN_GIO_SPARE

eivholt
eivholt over 5 years ago

Hi, I'm having some problems with interrupts. I want the available pin GIO to trigger an interrupt in my code. So far I have started with bdk_blinky and been able to read the pin configured as such:

Sys_DIO_Config(PIN_GIO_SPARE, DIO_NO_PULL | DIO_LPF_ENABLE | DIO_MODE_GPIO_IN_0);

I am trying to understand the API on how to configure interrupts. I have tried this:

 

Sys_DIO_IntConfig(0,

DIO_DEBOUNCE_ENABLE |

DIO_SRC_DIO_0 |

DIO_EVENT_HIGH_LEVEL,

DIO_DEBOUNCE_SLOWCLK_DIV32,

0);

 

experimenting with the parameters. I have implemented:

 

void DIO0_IRQHandler(void){

LED_On(LED_BLUE);

}

 

with breakpoint. It never hits.

 

Can anyone explain what index and DIO_SRC_DIO_* means in this context and what I can use? Should I use another library?

I tried to modify the bdk_button to use the PIN_GIO_SPARE pin instead of button0, but to no avail.

  • Sign in to reply
  • Cancel

Top Replies

  • eivholt
    eivholt over 5 years ago in reply to eivholt +1
    The interrupt handles override the default ones regardless of them being defined extern or not. See the next post about conditions before registrering interrupts. Learning something about C every day
  • shabaz
    shabaz over 5 years ago

    Hi Eivind,

     

    I have not checked the documentation, but I know how I would find out, so I can point you in the right direction.

    The DIO_SRC_DIO_0 is most likely (I'm guessing) indicating which pin you wish to use for the interrupt. The RSL10 chip is unusual (in a good way) in that any pin can be used for any feature, as far as I know (I could be wrong). Anyway, if you want to be certain how to use that API call, just hit F3 in the IDE, and it will find the definition and it will be described.

    To me it doesn't seem any other library needs to be used. You're currently using C and a low-level API which should meet your needs for things like I/O and interrupts.

    It looks very straightforward. As for breakpoints, I have not used them with the RSL10. Maybe you're running in Release mode instead of Debug mode. Anyway, you could step through if you really wanted to. Alternatively as a workaround, you could just light an LED to test how far in the code you have got.

    EDIT: One more thing, perhaps interrupts need to be enabled globally too. Usually (at least with other microcontrollers), once you have configured up individual interrupts, there's a master-control to enable or disable that configuration.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eivholt
    eivholt over 5 years ago in reply to shabaz

    For anyone joining in you can check out the relevant API documentation here. I came over this code and plan to explore the function DIO_SRC( to see if it performs any mapping magic. I'll also post the complete code. I did not perform any masking, disabling or clearing of the interrupt registers, as I thought that was only relevant if using more than one interrupt. Maybe this is the issue.

     

    /* Mask all interrupts */

        __set_PRIMASK(PRIMASK_DISABLE_INTERRUPTS);

     

        /* Disable all existing interrupts, clearing all pending source */

        Sys_NVIC_DisableAllInt();

        Sys_NVIC_ClearAllPendingInt();

    The documentation isn't very informative on when this has to be done, so any explanation would be welcome.

    I have interrupt handlers on DIO0 through DIO3, and they lit leds and have breakpoints.

     

    I will investigate the suggestion of globally enabling interrupts, thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eivholt
    eivholt over 5 years ago

    I believe I have found a likely explanation for the interrupt handlers not triggering; I did not realize I had to declare the handler like this:

    extern void DIO0_IRQHandler(void);

    My implementation does not declare the override in the right scope and the default implementations are probably still being run. At least it's worth checking out. Will post an update.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eivholt
    eivholt over 5 years ago

    I confirmed that my issue was due to missing this before configuring the interrupt:

     

    /* Mask all interrupts */

    __set_PRIMASK(PRIMASK_DISABLE_INTERRUPTS);

     

    /* Disable all existing interrupts, clearing all pending source */

    Sys_NVIC_DisableAllInt();

    Sys_NVIC_ClearAllPendingInt();

     

    And after that:

    /* Enable interrupts */

    NVIC_EnableIRQ(DIO0_IRQn);

    NVIC_EnableIRQ(I2C_IRQn);

     

    /* Unmask all interrupts */

    __set_PRIMASK(PRIMASK_ENABLE_INTERRUPTS);

     

    So I am wondering if omiting this leads to the interrupt configuration being overridden. Any one able to explain?

    I am happy to be able to proceed with interrupts now, I hope someone else finds it helpful.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eivholt
    eivholt over 5 years ago in reply to eivholt

    The interrupt handles override the default ones regardless of them being defined extern or not. See the next post about conditions before registrering interrupts. Learning something about C every day image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • mahmood.hassan
    mahmood.hassan over 5 years ago in reply to shabaz

    Yes it is true that any GPIO can be used for any digital function.

    DIO-0 to DIO-3 are analog inputs and again any of these pin can be connected with any channel of ADC.

     

    The DIO_SRC_DIO_0 is most likely (I'm guessing) indicating which pin you wish to use for the interrupt. The RSL10 chip is unusual (in a good way) in that any pin can be used for any feature, as far as I know (I could be wrong). Anyway, if you want to be certain how to use that API call, just hit F3 in the IDE, and it will find the definition and it will be described.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mahmood.hassan
    mahmood.hassan over 5 years ago in reply to eivholt

    Simplified solution.

    NVIC_DisableIRQ(DIO0_IRQn);
    Sys_DIO_Config(PIN_GIO_SPARE, DIO_NO_PULL | DIO_LPF_ENABLE | DIO_MODE_GPIO_IN_0);
    Sys_DIO_IntConfig(0, PIN_GIO_SPARE | DIO_EVENT_FALLING_EDGE | DIO_DEBOUNCE_ENABLE , DIO_DEBOUNCE_SLOWCLK_DIV32, 0);
    NVIC_ClearPendingIRQ(DIO0_IRQn);
    NVIC_EnableIRQ(DIO0_IRQn);

     

    Interrupt handler function

    void DIO0_IRQHandler(void)
    {
        LED_Toggle(PIN_LED_RED);
    }

     

    No need to disable all the interrupts. You can also use DIO1_IRQn, DIO2_IRQn or DIO3_IRQn with PIN_GIO_SPARE.

     

    * External pull-up resistor is required because we will be detecting falling edge and GPIO is configured without any pull up/down setting.

    • Cancel
    • Vote Up 0 Vote Down
    • 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 © 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