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.
#include "nrf_esb.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "sdk_common.h"
#include "nrf.h"
#include "nrf_error.h"
#include "nrf_esb_error_codes.h"
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "boards.h"
#include "app_util.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#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;
uint32_t gpio_check()
{
uint32_t err_code;
if(NRF_GPIOTE->EVENTS_PORT)
{
NRF_LOG_INFO("NRF_GPIOTE->EVENTS_PORT %d\n",NRF_GPIOTE->EVENTS_PORT);
NRF_LOG_PROCESS();
NRF_GPIOTE->EVENTS_PORT = 0;
}
nrf_delay_ms(100);
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)
{
bsp_board_led_invert(0);
}
if (button_state_2 == BTN_PRESSED)
{
bsp_board_led_invert(1);
}
if (button_state_3 == BTN_PRESSED)
{
bsp_board_led_invert(2);
}
if (button_state_4 == BTN_PRESSED)
{
bsp_board_led_invert(3);
}
nrf_delay_ms(100);
return NRF_SUCCESS;
}
#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_delay_ms(1);
bsp_board_init(BSP_INIT_LEDS);
NRF_GPIOTE->EVENTS_PORT |= (1 << BUTTON_1);
// Enable interrupt:
//NVIC_EnableIRQ(GPIOTE_IRQn);
//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);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEFAULT_BACKENDS_INIT();
}
int main(void)
{
uint32_t err_code;
log_init();
gpio_init();
while (true)
{
// Check state of all buttons with the button press, and toggle LED
err_code = gpio_check();
#if 1
__SEV();
__WFE();
__WFE();
#endif
}
}
/*lint -restore */
I have attached simple test file main.c