0

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

jorge gravatar image

asked 2016-04-28 18:01:25 +0100

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...

edit retag flag offensive close delete report spam

2 answers

Sort by » oldest newest most voted
1
kme gravatar image

answered 2016-04-29 16:46:31 +0100

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.

edit flag offensive delete publish link more
0
metcenger gravatar image

answered 2017-11-14 14:31:42 +0100

I try to use external interrupt from pin.

Use example \examples\peripheral\pin_change_int

but doesn't work. I can't receive handler in_pin_handler()

my code:

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
HAL_GPIO_EXTI_Callback();
}

static void gpio_init2(void)

{
ret_code_t err_code;

err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);

//    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
in_config.pull = NRF_GPIO_PIN_NOPULL;

err_code = nrf_drv_gpiote_in_init(INT1, &in_config, in_pin_handler);
APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_event_enable(INT1, true);
}

where is my wrong?

edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower

Stats

Asked: 2016-04-28 18:01:25 +0100

Seen: 414 times

Last updated: nov. 14