RTOS-SDK GPIO interrupt is causing reset

meaepeppe
Posts: 3
Joined: Tue May 31, 2016 3:52 pm

RTOS-SDK GPIO interrupt is causing reset

Postby meaepeppe » Tue May 31, 2016 4:09 pm

Hello! I would like to get my ESP8266 GPIO interrupt working but I can't so far. I'm going to attach the interested part of the code.
My goal is to set an interrupt on GPIO0 using the OS-SDK drivers and toggle GPIO4 value according to the GPIO0 button press. Right now, when I press the button, triggering the GPIO0 pin, nothing happens.

UPDATE: now the interrupt is fired. The problem was passing GPIO_ID_PIN(0) in key_init_single() instead of GPIO_Pin_0. But now, as soon as I press the GPIO0 switch, there are multiple system reset of the module. I already disabled the internal pull up in key.c because I put an external pull up on the PCB. Which could be the possible cause?

Thanks for your help.

Code: Select all

#include "esp_common.h"
#include "esp8266/gpio_register.h"

#include "gpio.h"
#include "key.h"
#include "user_config.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

LOCAL struct keys_param keys;
LOCAL struct single_key_param *single_key[KEY_NUM];
LOCAL int state=0;
xTaskHandle switch_set_point;

LOCAL void
key_shortPress(){
   state^=1;
   //GPIO_OUTPUT_SET(GPIO_ID_PIN(4), state);
   printf("Short_press %d\n",state);
   return;
}
LOCAL void
key_longPress(){
   printf("Long_press\n");
   return;
}
void switch_set (void *pvParameters){
   //output configuration----------------------------------------------------------------------
   GPIO_ConfigTypeDef gpio_out_cfg;                                       
       gpio_out_cfg.GPIO_Mode = GPIO_Mode_Output;
       gpio_out_cfg.GPIO_Pin  = GPIO_Pin_4;
       gpio_config(&gpio_out_cfg);                                       
   //input configuration----------------------------------------------------------------------
   //declaring the input key
   single_key[0]=key_init_single(GPIO_ID_PIN(0),PERIPHS_IO_MUX_GPIO0_U,FUNC_GPIO0,key_longPress,key_shortPress);
   keys.key_num = KEY_NUM;
   keys.single_key = single_key;
   key_init(&keys);
   printf("set_interrupt and closing task\n");
   vTaskDelete(switch_set_point);
}

void ICACHE_FLASH_ATTR
user_init(void)
{
    printf("SDK version:%s\n", system_get_sdk_version());

    /* need to set opmode before you set config */
    wifi_set_opmode(STATION_MODE);

    xTaskCreate(switch_set, "switch_set", 256, NULL, (1), &switch_set_point);
}



ESP_Alfred
Posts: 56
Joined: Mon Nov 10, 2014 7:31 pm

Re: RTOS-SDK GPIO interrupt is causing reset

Postby ESP_Alfred » Sun Jun 12, 2016 2:19 pm

I have test your code, the key press is nomal. It's allowable that external pull-up replace the internal pull-up.

The attachment is key.c and key.h, for your reference.

if the problem haven't been solved, please gave me the uart log and bin file.
Attachments
key demo.rar
(1.89 KiB) Downloaded 86 times

ashoke11
Posts: 1
Joined: Mon Sep 11, 2017 10:51 am

Re: RTOS-SDK GPIO interrupt is causing reset

Postby ashoke11 » Mon Sep 11, 2017 11:00 am

Hi

I was trying to use GPIO pins in interrupt mode to work as keys. Used the key.c provided in the sdk. But it worked weirdly.

When I am using 3 keys (GPIO 0,2,5): Interrupts and everything perfectly.
When I am using more than 3 keys (say GPIO 0,2,5,3): Except GPIO0, interrupts from all other keys are resetting the 8266 after few seconds.

My SDK Version is :SDK - RTOS SDK 1.3

Do you have a clue why this is happening? The code you have shared (key.c) is different to what I got in RTOS SDK 1.3.
Did not find a reference to gpio_config(pGPIOConfig) function. Can you please clarify?

Regards
Ashoke Sen

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest