Pin interrupt only running once?

AndrewM
Posts: 5
Joined: Fri Jul 19, 2019 10:43 pm

Pin interrupt only running once?

Postby AndrewM » Thu Sep 19, 2019 9:02 pm

Hi,

I have GPIO17 set as an input interrupt pin with pullup/down disabled, and I'm using an external pullup resistor. This is connected to an optosiolator (LTV-844). I'm feeding the optoisolater a 60Hz test signal, so I should be getting interrupts at 120Hz.

However, the interrupt seems to only run once.

What am I doing wrong here?

Code: Select all

    uint64_t inmask = (1ULL << 17);
    gpio_config_t input_conf;
    input_conf.pin_bit_mask = inmask;
    input_conf.mode = GPIO_MODE_INPUT;
    input_conf.pull_up_en = 0; //disable pullup
    input_conf.pull_down_en = 0; //disable pulldown
    input_conf.intr_type = 0; //disable interrupts
    gpio_config(&input_conf);
    
    gpio_install_isr_service(ESP_INTR_FLAG_EDGE | ESP_INTR_FLAG_IRAM);
    gpio_isr_handler_add(17, input_isr_handler, NULL);
    gpio_set_intr_type(17, GPIO_INTR_NEGEDGE);
    gpio_intr_enable(17);

Code: Select all

    bool testflag = false;
    
static void IRAM_ATTR input_isr_handler(void* arg) {
	current_input_low = gpio_input_get();
    	current_input_high = gpio_input_get_high();
    	if(testflag) {
        	GPIO.enable_w1ts = 23;
        	testflag = false;
    	} else {
        	GPIO.enable_w1tc = 23;
        	testflag = true;
    	}
    	ets_printf("\nInterrupt\n");
}
I've checked that I am getting a good 120Hz signal on the pin (see: https://i.imgur.com/9EB3Bb8.png)

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Pin interrupt only running once?

Postby WiFive » Fri Sep 20, 2019 5:10 am

Code: Select all

GPIO.enable_w1ts = 23
Not

Code: Select all

GPIO.enable_w1ts = 1 << 23
?

AndrewM
Posts: 5
Joined: Fri Jul 19, 2019 10:43 pm

Re: Pin interrupt only running once?

Postby AndrewM » Sat Sep 21, 2019 4:41 pm

I fixed that 1 << 23 error.

The interrupt still only fires once.

I only get one printout per restart of "Interrupt" to the serial monitor, and the P23 output goes low and stays low.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Pin interrupt only running once?

Postby Ritesh » Sat Sep 21, 2019 6:41 pm

AndrewM wrote:
Thu Sep 19, 2019 9:02 pm
Hi,

I have GPIO17 set as an input interrupt pin with pullup/down disabled, and I'm using an external pullup resistor. This is connected to an optosiolator (LTV-844). I'm feeding the optoisolater a 60Hz test signal, so I should be getting interrupts at 120Hz.

However, the interrupt seems to only run once.

What am I doing wrong here?

Code: Select all

    uint64_t inmask = (1ULL << 17);
    gpio_config_t input_conf;
    input_conf.pin_bit_mask = inmask;
    input_conf.mode = GPIO_MODE_INPUT;
    input_conf.pull_up_en = 0; //disable pullup
    input_conf.pull_down_en = 0; //disable pulldown
    input_conf.intr_type = 0; //disable interrupts
    gpio_config(&input_conf);
    
    gpio_install_isr_service(ESP_INTR_FLAG_EDGE | ESP_INTR_FLAG_IRAM);
    gpio_isr_handler_add(17, input_isr_handler, NULL);
    gpio_set_intr_type(17, GPIO_INTR_NEGEDGE);
    gpio_intr_enable(17);

Code: Select all

    bool testflag = false;
    
static void IRAM_ATTR input_isr_handler(void* arg) {
	current_input_low = gpio_input_get();
    	current_input_high = gpio_input_get_high();
    	if(testflag) {
        	GPIO.enable_w1ts = 23;
        	testflag = false;
    	} else {
        	GPIO.enable_w1tc = 23;
        	testflag = true;
    	}
    	ets_printf("\nInterrupt\n");
}
I've checked that I am getting a good 120Hz signal on the pin (see: https://i.imgur.com/9EB3Bb8.png)
Hello,

Did you check interrupt example provided with ESP32 IDF as example? Which IDF you are using?
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Bing [Bot] and 230 guests