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

GPIOTE manual clear

Hello,

I am working with the GPIOTE library to get a GPIOTE_IRQ from a peripheral.

I have several questions regarding the library and how IRQ works.

1.How do I clear the event for the gpiote input. I know that void GPIOTE_IRQHandler(void) does the clearing for you but I am wondering if there is a way I can clear it when I need to. This needs to happen because I need to do something while I am in my GPIOTE_IRQHandler when there is another GPIOTE_IRQ signal coming from the peripheral.

I know that I can use nrf_drv_gpiote_in_is_set(GPIOPE_IRQ_Pin) to check if the pin is set. However, the only function that actually clears the event needs an event input

__STATIC_INLINE void nrf_gpiote_event_clear	(	nrf_gpiote_events_t 	event	)

So I though of using

uint32_t nrf_drv_gpiote_in_event_addr_get	(	nrf_drv_gpiote_pin_t 	pin	)	

and manually subtracting NRF_GPIOTE to get the event and use

__STATIC_INLINE void nrf_gpiote_event_clear	(	nrf_gpiote_events_t 	event	)	

Is there a better way of clearing the event?

2 Also, I was wondering about the behavior of the IRQ when I manually clear it. Will clearing the event cause the void GPIOTE_IRQHandler(void) not be called or will it be called anyway.

Thank you, John Lee

Parents
  • you can clear NRF_GPIOTE->EVENT_PORT or NRF_GPIOTE->EVENTS_IN[x] manually by writing 0 to them.

    NRF_GPIOTE->EVENT_PORT = 0;
    NRF_GPIOTE->EVENTS_IN[0] = 0;
    NRF_GPIOTE->EVENTS_IN[1] = 0;
    NRF_GPIOTE->EVENTS_IN[2] = 0;
    NRF_GPIOTE->EVENTS_IN[3] = 0;
    
  • @JohnLee: It's not easy to clear an interrupt before the interrupt handle is executed.

    You can only do that if you are in an another interrupt handler with same or higher priority.

    If it's the case then the interrupt that has been cleared will not be able to trigger the IRQHandler().

    If you are in the context with lower priority , for example in the main loop, then the IRQHandler() will preempt the normal routine and you can't clear the flag before IRQHandler() executed.

Reply
  • @JohnLee: It's not easy to clear an interrupt before the interrupt handle is executed.

    You can only do that if you are in an another interrupt handler with same or higher priority.

    If it's the case then the interrupt that has been cleared will not be able to trigger the IRQHandler().

    If you are in the context with lower priority , for example in the main loop, then the IRQHandler() will preempt the normal routine and you can't clear the flag before IRQHandler() executed.

Children
No Data
Related