This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use the GPIOTE_IRQHandler for two or more different events?

Hello

I'm trying to implement a number of different interrupts using the nRF51 DK but I'm having trouble understanding how to use the GPIOTE_IRQHandler function.

Basically, I need one interrupt to sense a pin that will be used for sending the device in and out of sleep mode, and a second interrupt for toggling an LED from a different pin. I've tried looking at the other examples mentioned on Devzone but its not clear to me how to structure the GPIOTE_IRQHandler function and how to use the PORT functionality (since it uses less power apparently).

For example, how would I change the code here to add an additional interrupt to toggle an LED?

github.com/.../main.c

Thanks

Parents
  • Just so you know, you can also use the GPIOTE handling library.

    PORT event uses less power, but when you use PORT event you don't know which pin that is generating the event (unless you only have activated one pin).

    The GPIOTE only has one interrupt, and in its interrupt handler you need to check which pin that generated the event. This can be done by examining NRF_GPIO->IN. If it is the correct pin you can toggle the LED.

    The PORT event is generated by the DETECT signal, and to get the DETECT signal you need to enable sense on that ping using nrf_gpio_cfg_sense_input().

Reply
  • Just so you know, you can also use the GPIOTE handling library.

    PORT event uses less power, but when you use PORT event you don't know which pin that is generating the event (unless you only have activated one pin).

    The GPIOTE only has one interrupt, and in its interrupt handler you need to check which pin that generated the event. This can be done by examining NRF_GPIO->IN. If it is the correct pin you can toggle the LED.

    The PORT event is generated by the DETECT signal, and to get the DETECT signal you need to enable sense on that ping using nrf_gpio_cfg_sense_input().

Children
No Data
Related