Two GPIO Interrupts running continuosly .

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

Two GPIO Interrupts running continuosly .

Postby dhananjay.sutariya » Tue Mar 12, 2019 5:26 am

Hi guys,
I'm trying to run two gpio inbuilt interrupts example. But both my interrupts take on the main code as soon as i connect a jumper to the pin.
I guess there is a floating pin issue in which case i'm taking a 4.7 k Ohm Resistor and a .1 uF capacitor also i've changed the gpio pins to 34 35 and still the same thing is happening . Please help.

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Two GPIO Interrupts running continuosly .

Postby ESP_Sprite » Tue Mar 12, 2019 7:27 am

Can you post your code?

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

Re: Two GPIO Interrupts running continuosly .

Postby dhananjay.sutariya » Tue Mar 12, 2019 8:01 am

#define GPIO_INPUT_IO_0 4
#define GPIO_INPUT_IO_1 5
void gpio_initialise(gpio_config_t io,void *gpio_isr_handler,char pin_no)
{
gpio_config(&io);

if(gpio_isr_handler!=NULL)
{
gpio_install_isr_service(0);

gpio_isr_handler_add(temp,gpio_isr_handler,(void*)pin_no);

}
}


#define GPIO_OUTPUT_IO_0 18
static void IRAM_ATTR gpio_isr_handler1(TaskHandle_t Handle)
{
// int pin_no=(int)Handle;
// if(pin_no==GPIO_INPUT_IO_0)
level=0;
// else
// level=1;

}
static void IRAM_ATTR gpio_isr_handler2(TaskHandle_t Handle)
{
// int pin_no=(int)Handle;
// if(pin_no==GPIO_INPUT_IO_0)
level=1;
// else
}



void app_main()
{
gpio_config_t io_conf0,io_conf1,io_conf2;

io_conf0.intr_type=GPIO_PIN_INTR_NEGEDGE;
io_conf0.mode = GPIO_MODE_INPUT;
io_conf0.pin_bit_mask = (1ULL<<GPIO_INPUT_IO_0);
io_conf0.pull_down_en = 1;
gpio_initialise(io_conf0,gpio_isr_handler1,GPIO_INPUT_IO_0);

io_conf1.intr_type=GPIO_PIN_INTR_POSEDGE;
io_conf1.mode = GPIO_MODE_INPUT;
io_conf1.pin_bit_mask = (1ULL<<GPIO_INPUT_IO_1);
io_conf1.pull_down_en = 1;
gpio_initialise(io_conf1,gpio_isr_handler2,GPIO_INPUT_IO_1);


gpio_set_direction(GPIO_OUTPUT_IO_0,GPIO_MODE_OUTPUT);

while(1)
{/*
gpio_high(GPIO_OUTPUT_IO_0);
vTaskDelay(1000/portTICK_PERIOD_MS);
gpio_low(GPIO_OUTPUT_IO_0);
vTaskDelay(1000/portTICK_PERIOD_MS);
*/
printf("Level :%d\n",level);
// prev_state=level;
vTaskDelay(20/portTICK_PERIOD_MS);
// if(level==prev_state)
gpio_set_level(GPIO_OUTPUT_IO_0,level);

fflush(stdout);
}

The code works fine up and untill i change the interrupt pins to 34 and 35

Who is online

Users browsing this forum: No registered users and 80 guests