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

GPIOTE event not coming

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

Parents
  • if i enable GPIOTE IRQ interrupt, i am getting the interrupts in low power mode but I don't want use interrupts.

     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?

  • hi Jared,

    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?

    or

    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. 

  • Yes, PORT interrupt should be enabled in NRF_GPIOTE->INTENSET to wake up on that event. If you don't want to use an interrupt, just don't enable it in NVIC.

  • i added below lin of code 

    NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Set << GPIOTE_INTENSET_PORT_Pos;

    to gpio_init() but still event is not coming.

  • __SEV();
    __WFE();
    __WFE();

    it seems should be different order: __WFE(); __SEV(); __WFE();

Reply Children
Related