ESP8266 Developer Zone The Official ESP8266 Forum 2016-06-12T10:29:41+08:00 https://bbs.espressif.com:443/feed.php?f=66&t=2247 2016-06-12T10:29:41+08:00 2016-06-12T10:29:41+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2247&p=7280#p7280 <![CDATA[Re: RTOS SDK cannot start timer from interrupt handler]]>
You need to disable the GPIO interrupt as the sample code we gave.

Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Sun Jun 12, 2016 10:29 am


]]>
2016-06-08T19:05:18+08:00 2016-06-08T19:05:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2247&p=7264#p7264 <![CDATA[Re: RTOS SDK cannot start timer from interrupt handler]]>
Either way, your code works.

Statistics: Posted by gustavo — Wed Jun 08, 2016 7:05 pm


]]>
2016-06-07T19:40:57+08:00 2016-06-07T19:40:57+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2247&p=7246#p7246 <![CDATA[Re: RTOS SDK cannot start timer from interrupt handler]]>
Please try this

Code:

#include "esp_common.h"
#include "esp_timer.h"
#include "gpio.h"
static os_timer_t some_timer;

static void timer_handler(void* args) {
   
    printf("timer");
}


static void intr_handler() {
   
    u32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
    gpio_pin_intr_state_set(GPIO_ID_PIN(12) , GPIO_PIN_INTR_DISABLE);
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status & BIT(12) );

    //printf("a,");   
    portENTER_CRITICAL();
   
    //printf("b,");
    os_timer_disarm(&some_timer);
    os_timer_setfn(&some_timer, (os_timer_func_t *)timer_handler, NULL);
    os_timer_arm(&some_timer, 3, 1);
    //printf("c,");
    portEXIT_CRITICAL();
    //printf("d\n");

        gpio_pin_intr_state_set(GPIO_ID_PIN(12) ,GPIO_PIN_INTR_NEGEDGE);
}

void user_init(void)
{
    GPIO_ConfigTypeDef gpio_in_cfg12;
    gpio_in_cfg12.GPIO_Pin  = GPIO_Pin_12;
    gpio_in_cfg12.GPIO_IntrType = GPIO_PIN_INTR_NEGEDGE;
    gpio_in_cfg12.GPIO_Mode = GPIO_Mode_Input;
    gpio_in_cfg12.GPIO_Pullup = GPIO_PullUp_EN;
    gpio_config(&gpio_in_cfg12);

    gpio_intr_handler_register(intr_handler, NULL);
    _xt_isr_unmask(1 << ETS_GPIO_INUM);
}


If your problem is still unsolved, please feel free to let us know.

Statistics: Posted by ESP_Faye — Tue Jun 07, 2016 7:40 pm


]]>
2016-06-02T23:08:44+08:00 2016-06-02T23:08:44+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2247&p=7183#p7183 <![CDATA[RTOS SDK cannot start timer from interrupt handler]]> I'm trying to implement debounce when the user clicks a button.

I need to start the debounce timer from within the gpio interrupt. However this leads to a crash.

My code is as follows.

Code:

#include "gpio.h"
#include "esp_common.h"
#include "esp_timer.h"

static os_timer_t some_timer;

static void timer_handler(void* args) {
   
    printf("timer");
}

static void intr_handler() {
   
    portENTER_CRITICAL();

    os_timer_disarm(&some_timer);
    os_timer_setfn(&some_timer, (os_timer_func_t *)timer_handler, NULL);
    os_timer_arm(&some_timer, 3, 1);

    portEXIT_CRITICAL();
}

void user_init(void)
{
    GPIO_ConfigTypeDef gpio_in_cfg12;
    gpio_in_cfg12.GPIO_Pin  = GPIO_Pin_12;
    gpio_in_cfg12.GPIO_IntrType = GPIO_PIN_INTR_NEGEDGE;
    gpio_in_cfg12.GPIO_Mode = GPIO_Mode_Input;
    gpio_in_cfg12.GPIO_Pullup = GPIO_PullUp_EN;
    gpio_config(&gpio_in_cfg12);

    gpio_intr_handler_register(intr_handler, NULL);
    _xt_isr_unmask(1 << ETS_GPIO_INUM);
}


The only output I get is:

Code:

ShowCritical:1


Edit: If I start the timer from user_init, everything works as planned.

Statistics: Posted by gustavo — Thu Jun 02, 2016 11:08 pm


]]>