I have enable 4 Low power events for 4 button in NRF52832 board. when i press a button board is waking up due to low power event
but when it is waiting in low power mode using sequence __sev(); __wfe(); __wfe(); events are not coming.
if i enable GPIOTE IRQ interrupt, i am getting the interrupts in low power mode but I don't want use interrupts.
#define BTN_PRESSED 0 /**< Value of a pressed button. */
#define BTN_RELEASED 1 /**< Value of a released button. */
static uint32_t button_state_1;
static uint32_t button_state_2;
static uint32_t button_state_3;
static uint32_t button_state_4;
NRF_GPIOTE->EVENTS_PORT = 0;
button_state_1 = nrf_gpio_pin_read(BUTTON_1);
button_state_2 = nrf_gpio_pin_read(BUTTON_2);
button_state_3 = nrf_gpio_pin_read(BUTTON_3);
button_state_4 = nrf_gpio_pin_read(BUTTON_4);
if (button_state_1 == BTN_PRESSED)
if (button_state_2 == BTN_PRESSED)
if (button_state_3 == BTN_PRESSED)
if (button_state_4 == BTN_PRESSED)
#define MY_BUTTON BUTTON_1
#define MY_LED LED_2
void gpio_init( void )
nrf_gpio_cfg_sense_input(BUTTON_1, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(BUTTON_2, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(BUTTON_3, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(BUTTON_4, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
// Workaround for PAN_028 rev1.1 anomaly 22 - System: Issues with disable System OFF mechanism
NRF_GPIOTE->EVENTS_PORT |= (1 << BUTTON_1);
// Enable interrupt:
//NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Set << GPIOTE_INTENSET_PORT_Pos;
/**@brief Function for initializing the nrf log module.
static void log_init(void)
ret_code_t err_code = NRF_LOG_INIT(NULL);
// Check state of all buttons with the button press, and toggle LED
err_code = gpio_check();
/*lint -restore */
I have attached simple test file main.c
What do you mean? How does this differ from what you want to achieve? I'm not sure I understand the issue.
thanks for your reply.
I have provided a simple code. in that, I enabled 4 GPIOTE events.
if i am going to systemoff instead of waiting in low power mode NRF52832 is waking up.
Q1.can GPIOTE events cant make NRF52832 come out of low power mode?
Q2. GPIOTE events won't come when system_on condition?
This is surely not the intended way of using the GPIOTE peripheral. The whole idea of GPIOTE is to automatically do tasks based on events without involving the CPU. I suggest looking at the BSP example, it does somewhat what you're trying to do and implements IDLE sleep.
I don't understand "This is surely not the intended way of using the GPIOTE peripheral. "
GPIOTE event will be generated when I press a button (as per my configuration) and is working if I goto system_off mode. but when the system is on, the GPIOTE event is not coming. do you mean to say GPIOTE events will not come in system_on condition?
GPIOTE will only work to wakeup system from off?
Surya said:GPIOTE event will be generated when I press a button (as per my configuration) and is working if I goto system_off mode. but when the system is on, the GPIOTE event is not coming. do you mean to say GPIOTE events will not come in system_on condition?
no, that's not what I meant. I can see that your program does somewhat what you intended it to do. But there is a better way to make nRF do something based on what button that is pressed ( See the BSP example).
Surya said: do you mean to say GPIOTE events will not come in system_on condition?
From the product specification:
"PORT is an event that can be generated from multiple input pins using the GPIO DETECT signal.
The event will be generated on the rising edge of the DETECT signal. See GPIO — General purpose input/output for more information about the DETECT signal.
Putting the system into System ON IDLE while DETECT is high will not cause DETECT to wake the system up again. Make sure to clear all DETECT sources before entering sleep. If the LATCH register is used as a source, if any bit in LATCH is still high after clearing all or part of the register (for instance due to one of the PINx.DETECT signal still high), a new rising edge will be generated on DETECT, see Pin configuration.
Trying to put the system to System OFF while DETECT is high will cause a wakeup from System OFF reset.
This feature is always enabled although the peripheral itself appears to be IDLE, that is, no clocks or other power intensive infrastructure have to be requested to keep this feature enabled. This feature can therefore be used to wake up the CPU from a WFI or WFE type sleep in System ON with all peripherals and the CPU idle, that is, lowest power consumption in System ON mode.
In order to prevent spurious interrupts from the PORT event while configuring the sources, the user shall first disable interrupts on the PORT event (through INTENCLR.PORT), then configure the sources (PIN_CNF[n].SENSE), clear any potential event that could have occurred during configuration (write '1' to EVENTS_PORT), and finally enable interrupts (through INTENSET.PORT)".
The interrupt has to be enabled for it to work.