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

How to handle GPIO interrupts while it is configures to SENSE low

Hi all: All of the example code is using GPIOTE to demonstrate how to handle GPIO interrupt. However, it just can configured HiTOLow/LowToHi/Toggle. If I want to trigger the interrupt by sense Low/High, how can I implement the function. For example, we can register a event handler by calling the function of nrf_drv_gpiote_in_init(). How can I register a event handler to handle GPIO interrupts while it sense LOW/HIGH?

Thanks...

Parents
  • Hi, there are two example projects in the SDK that show usage of the gpiote module:

    \examples\peripheral\pin_change_int
    \examples\peripheral\gpiote

    Typically you initialize the gpiote module with nrf_drv_gpiote_init(), and then for each input pin you want to generate an interrupt you add nrf_drv_gpiote_in_init(), with a parameter to the event handler that should execute on pin change.

    You will notice that the gpiote driver is using the SENSE mechanism only, and not any of the IN events. Main reason for this is that the current consumption is much lower by using SENSE detect, and you are not limited to only 4 pins (there are only 4 configurable IN events).

    Typically the 4 OUT tasks and 4 IN events are used to control something directly through PPI without CPU interaction. For instance one of the examples show how a compare0 event from a timer can toggle an output pin directly.

Reply
  • Hi, there are two example projects in the SDK that show usage of the gpiote module:

    \examples\peripheral\pin_change_int
    \examples\peripheral\gpiote

    Typically you initialize the gpiote module with nrf_drv_gpiote_init(), and then for each input pin you want to generate an interrupt you add nrf_drv_gpiote_in_init(), with a parameter to the event handler that should execute on pin change.

    You will notice that the gpiote driver is using the SENSE mechanism only, and not any of the IN events. Main reason for this is that the current consumption is much lower by using SENSE detect, and you are not limited to only 4 pins (there are only 4 configurable IN events).

    Typically the 4 OUT tasks and 4 IN events are used to control something directly through PPI without CPU interaction. For instance one of the examples show how a compare0 event from a timer can toggle an output pin directly.

Children
No Data
Related