gpio_intr_handler_register cause wdt reset

baoshi
Posts: 23
Joined: Tue Dec 02, 2014 8:35 pm

gpio_intr_handler_register cause wdt reset

Postby baoshi » Tue Dec 01, 2015 9:09 pm

I've been relying on the following code for GPIO interrupt for quite some time:

Code: Select all

LOCAL void gpio_isr(void *arg)
{
  uint32 status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
  if (status & BIT(0))
  {
      ets_uart_printf("Pressed!\r\n");
      // Clear interrupt
      GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, status & BIT(0));
  }
}

void ICACHE_FLASH_ATTR user_init(void)
{
  uart_init(BIT_RATE_115200, BIT_RATE_115200);
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
  PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO0_U);
  GPIO_DIS_OUTPUT(GPIO_ID_PIN(0));
  ETS_GPIO_INTR_DISABLE();
  ETS_GPIO_INTR_ATTACH(gpio_isr, 0);
  gpio_pin_intr_state_set(GPIO_ID_PIN(0), GPIO_PIN_INTR_NEGEDGE);
  ETS_GPIO_INTR_ENABLE();
}


Recently I examined into gpio.h and decided to try the gpio_ functions, so I wrote this:

Code: Select all

void new_gpio_isr(uint32 intr_mask, void *arg)
{
  ets_uart_printf("int %d\r\n", intr_mask);
  if (intr_mask & BIT(0))
  {
      ets_uart_printf("Pressed!\r\n");
      // Clear interrupt
      gpio_intr_ack(intr_mask);
  }
}

void ICACHE_FLASH_ATTR user_init(void)
{
  uart_init(BIT_RATE_115200, BIT_RATE_115200);
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
  PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO0_U);
  GPIO_DIS_OUTPUT(GPIO_ID_PIN(0));
  ETS_GPIO_INTR_DISABLE();
  gpio_intr_handler_register(new_gpio_isr, 0);
  gpio_pin_intr_state_set(GPIO_ID_PIN(0), GPIO_PIN_INTR_NEGEDGE);
  ETS_GPIO_INTR_ENABLE();
}


And the system enter into watch dog reset soon after I press the button. This is tested with 1.4 to 1.5 SDK

Is there any difference between ETS_GPIO_INTR_ATTACH and gpio_intr_handler_register?

Thanks

Baoshi

Who is online

Users browsing this forum: No registered users and 20 guests