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

PORT event not waking up with interrupts disabled

Hi,

I'm building a low power application utilizing a MEMS accelerometer providing a data ready signal with configurable intervals. The intent is to use this signal as a wakeup from system_on sleep. The low power execution is in a loop where I do not need the execution overhead of interrupt handling. I tried to implement a wakeup using the port event without interrupts enabled, but in this case wakeup does not take place although the SEVONPEND is set. The essential code is below

NRF_GPIO->PIN_CNF[IO_MEMS_INT1_PIN] |= (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos);
NVIC_DisableIRQ(GPIOTE_IRQn);
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Enabled << GPIOTE_INTENSET_PORT_Pos;
while (1) {
	NRF_GPIOTE->EVENTS_PORT = 0;
	__SEV();		// Set event register
	__WFE();		// clear event register
	if (nrf_gpio_pin_read(IO_MEMS_INT1_PIN)) {
		__WFE();   // sleep
	}
// Read MEMS to clear data ready condition...
}

Execution does not leave __WFE when the pin goes down. If I change NVIC_DisableIRQ(GPIOTE_IRQn) to EnableIRQ, wake-up takes place and the interrupt executes properly. The documentation is in my opinion insufficient regarding the wake-up on event behavior. It is e.g. unclear whether the corresponding INTENSET bit relating to a event needs to be set for the wakeup to take place. I have a similar need for wakeup without interrupt for AD conversion and SPI master. I wouldn't like to have the execution go through the interrupts as it introduces additional execution overhead and moreover enforces state checking in the interrupt routines as I use them differently (and preferably exclusively) in another operation mode. As far as I've understood from the documentation it should be possible to achieve wakeup without interrupts enabled. How? My chip is NRF51822_QFACA1

Related