]> granicus.if.org Git - esp-idf/commitdiff
Mark some interrupts that are now allocated dynamically as free, add int handle param...
authorJeroen Domburg <git@j0h.nl>
Thu, 8 Dec 2016 04:38:22 +0000 (12:38 +0800)
committerJeroen Domburg <git@j0h.nl>
Thu, 8 Dec 2016 04:39:33 +0000 (12:39 +0800)
components/driver/include/driver/gpio.h
components/driver/include/driver/ledc.h
components/driver/include/driver/pcnt.h
components/driver/include/driver/timer.h
components/driver/include/driver/uart.h
components/driver/uart.c
components/esp32/include/soc/soc.h
components/esp32/intr_alloc.c
components/esp32/test/test_intr_alloc.c
examples/13_timer_group/main/timer_group.c

index 7f178677bc24a30a2e173dbeca9c2f82f5e79551..fba013fe8b9af6cf1de9fa6d6c84155cc213c8ad 100644 (file)
@@ -351,6 +351,8 @@ esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num);
  * @param  intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  *            ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  * @param  arg  Parameter for handler function
+ * @param  handle Pointer to return handle. If non-NULL, a handle for the interrupt will
+ *            be returned here.
  *
  * @return
  *     - ESP_OK Success ;
index 64305232522b58b4cc9dfe83e14d2beccdf48db1..fb97c6c011b628dd41b96176f7c5955129d1046d 100644 (file)
@@ -265,6 +265,8 @@ esp_err_t ledc_set_fade(ledc_mode_t speed_mode, uint32_t channel, uint32_t duty,
  * @param  intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  *            ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  * @param   arg Parameter for handler function
+ * @param  handle Pointer to return handle. If non-NULL, a handle for the interrupt will
+ *            be returned here.
  *
  * @return
  *     - ESP_OK Success
index d852f8fe7965e7a0df199e328e6f95ad1bc58a15..f5a10581c064ca292f47e5b852f15c86719cbd4b 100644 (file)
@@ -221,6 +221,8 @@ esp_err_t pcnt_get_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16
  * @param arg Parameter for handler function
  * @param  intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  *            ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
+ * @param  handle Pointer to return handle. If non-NULL, a handle for the interrupt will
+ *            be returned here.
  *
  * @return
  *     - ESP_OK Success
index f46e708734110b7a84bd5c70716ef556ae69b6da..134fd504fb7b0fa122b2c0d3bea75f1149f05f4b 100644 (file)
@@ -258,12 +258,15 @@ esp_err_t timer_set_alarm(timer_group_t group_num, timer_idx_t timer_num, timer_
  * @param timer_num Timer index of timer group
  * @param fn Interrupt handler function.
  *        @note
- *        Code inside the handler function can only call functions in IRAM,  so cannot call other timer APIs.
- *        Use direct register access to access timers from inside the ISR.
+ *        In case the this is called with the INIRAM flag, code inside the handler function can 
+ *        only call functions in IRAM, so it cannot call other timer APIs.
+ *        Use direct register access to access timers from inside the ISR in this case.
  *
  * @param arg Parameter for handler function
  * @param  intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  *            ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
+ * @param  handle Pointer to return handle. If non-NULL, a handle for the interrupt will
+ *            be returned here.
  * @return
  *     - ESP_OK Success
  *     - ESP_ERR_INVALID_ARG Function pointer error.
index be3a6c8fc664c1765fdfec4d4af00469a816e0ca..dd69dce275a860768d6fc8ed2f523b189ace6529 100644 (file)
@@ -379,6 +379,18 @@ esp_err_t uart_enable_tx_intr(uart_port_t uart_num, int enable, int thresh);
  */\r
 esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void*), void * arg, int intr_alloc_flags);\r
 \r
+
+/**\r
+ * @brief Free UART interrupt handler registered by uart_isr_register.\r
+ *\r
+ * @param uart_num UART_NUM_0, UART_NUM_1 or UART_NUM_2\r
+ *\r
+ * @return\r
+ *     - ESP_OK   Success\r
+ *     - ESP_FAIL Parameter error\r
+ */\r
+esp_err_t uart_isr_free(uart_port_t uart_num);
+\r
 /**\r
  * @brief Set UART pin number\r
  *\r
index 7ce560f62225b6efe7b62c148c4ea91e49ad9814..baf2d1f5a9ee24da0baa10ebe0ff0da708cae94a 100644 (file)
@@ -309,6 +309,19 @@ esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void*), void * arg,
     return ret;\r
 }\r
 \r
+\r
+esp_err_t uart_isr_free(uart_port_t uart_num)\r
+{\r
+    esp_err_t ret;
+    UART_CHECK((uart_num < UART_NUM_MAX), "uart_num error", ESP_FAIL);\r
+    if (p_uart_obj[uart_num]->intr_handle==NULL) return ESP_ERR_INVALID_ARG;\r
+    UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);\r
+    ret=esp_intr_free(p_uart_obj[uart_num]->intr_handle);\r
+    p_uart_obj[uart_num]->intr_handle=NULL;\r
+    UART_EXIT_CRITICAL(&uart_spinlock[uart_num]);\r
+    return ret;\r
+}\r
+\r
 //internal signal can be output to multiple GPIO pads\r
 //only one GPIO pad can connect with input signal\r
 esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int rts_io_num, int cts_io_num)\r
index 3991152f2137affc89bca92bd4a9b33393a67cfd..511456a1031ba92a6511470ed115a57a912f834a 100755 (executable)
  *      Intr num                Level           Type                    PRO CPU usage           APP CPU uasge
  *      0                       1               extern level            WMAC                    Reserved
  *      1                       1               extern level            BT/BLE Host VHCI        Reserved
- *      2                       1               extern level            FROM_CPU                FROM_CPU
- *      3                       1               extern level            TG0_WDT                 Reserved
+ *      2                       1               extern level
+ *      3                       1               extern level
  *      4                       1               extern level            WBB
  *      5                       1               extern level            BT Controller 
  *      6                       1               timer                   FreeRTOS Tick(L1)       FreeRTOS Tick(L1)
  *      7                       1               software                Reserved                Reserved
  *      8                       1               extern level            BLE Controller 
- *      9                       1               extern level            EMAC
+ *      9                       1               extern level
  *      10                      1               extern edge             Internal Timer
  *      11                      3               profiling
  *      12                      1               extern level
 //CPU0 Interrupt number reserved, not touch this.
 #define ETS_WMAC_INUM                           0
 #define ETS_BT_HOST_INUM                        1
-#define ETS_FROM_CPU_INUM                       2
-#define ETS_T0_WDT_INUM                         3
 #define ETS_WBB_INUM                            4
-#define ETS_EMAC_INUM                           9
 #define ETS_TG0_T1_INUM                         10 /**< use edge interrupt*/
 #define ETS_FRC1_INUM                           22
 #define ETS_T1_WDT_INUM                         24
index f17c56bc2004bb989f1e4315365a8b37949197b4..77572b1a576f23c533857974f10b828369c44663 100644 (file)
@@ -99,8 +99,8 @@ typedef struct {
 const static int_desc_t int_desc[32]={
     { 1, INTTP_LEVEL, {INTDESC_RESVD,  INTDESC_RESVD } }, //0
     { 1, INTTP_LEVEL, {INTDESC_RESVD,  INTDESC_RESVD } }, //1
-    { 1, INTTP_LEVEL, {INTDESC_RESVD,  INTDESC_RESVD } }, //2
-    { 1, INTTP_LEVEL, {INTDESC_RESVD,  INTDESC_RESVD } }, //3
+    { 1, INTTP_LEVEL, {INTDESC_NORMAL, INTDESC_NORMAL} }, //2
+    { 1, INTTP_LEVEL, {INTDESC_NORMAL, INTDESC_NORMAL} }, //3
     { 1, INTTP_LEVEL, {INTDESC_RESVD,  INTDESC_NORMAL} }, //4
     { 1, INTTP_LEVEL, {INTDESC_RESVD,  INTDESC_NORMAL} }, //5
     { 1, INTTP_NA,    {INT6RES,        INT6RES       } }, //6
@@ -602,7 +602,7 @@ esp_err_t esp_intr_free(intr_handle_t handle)
     if ((handle->vector_desc->flags&VECDESC_FL_NONSHARED) || free_shared_vector) {
         ESP_LOGV(TAG, "esp_intr_free: Disabling int, killing handler");
         //Reset to normal handler
-        xt_set_interrupt_handler(handle->vector_desc->intno, xt_unhandled_interrupt, (void*)handle->vector_desc->intno);
+        xt_set_interrupt_handler(handle->vector_desc->intno, xt_unhandled_interrupt, (void*)((int)handle->vector_desc->intno));
         //Theoretically, we could free the vector_desc... not sure if that's worth the few bytes of memory
         //we save.(We can also not use the same exit path for empty shared ints anymore if we delete 
         //the desc.) For now, just mark it as free. 
index 390079aa46674dd071b48a4326f1e24eea22f159..31991b4e41d205d37603a269109919890ff3e2b1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- Test for multicore FreeRTOS. This test spins up threads, fiddles with queues etc.
+ Tests for the interrupt allocator.
 */
 
 #include <esp_types.h>
@@ -25,9 +25,6 @@
 #define TIMER_INTERVAL1_SEC   (5.78)   /*!< test interval for timer 1 */
 
 
-/*
- * @brief timer group0 hardware timer1 init
- */
 static void my_timer_init(int timer_group, int timer_idx, int ival)
 {
     timer_config_t config;
@@ -55,38 +52,38 @@ static volatile int count[4]={0,0,0,0};
 static void timer_isr(void *arg)
 {
     int timer_idx = (int)arg;
-       count[timer_idx]++;
+    count[timer_idx]++;
     if (timer_idx==0) {
-               TIMERG0.int_clr_timers.t0 = 1;
-               TIMERG0.hw_timer[0].update=1;
-               TIMERG0.hw_timer[0].config.alarm_en = 1;
-       }
+        TIMERG0.int_clr_timers.t0 = 1;
+        TIMERG0.hw_timer[0].update=1;
+        TIMERG0.hw_timer[0].config.alarm_en = 1;
+    }
     if (timer_idx==1) {
-               TIMERG0.int_clr_timers.t1 = 1;
-               TIMERG0.hw_timer[1].update=1;
-               TIMERG0.hw_timer[1].config.alarm_en = 1;
-       }
+        TIMERG0.int_clr_timers.t1 = 1;
+        TIMERG0.hw_timer[1].update=1;
+        TIMERG0.hw_timer[1].config.alarm_en = 1;
+    }
     if (timer_idx==2) {
-               TIMERG1.int_clr_timers.t0 = 1;
-               TIMERG1.hw_timer[0].update=1;
-               TIMERG1.hw_timer[0].config.alarm_en = 1;
-       }
+        TIMERG1.int_clr_timers.t0 = 1;
+        TIMERG1.hw_timer[0].update=1;
+        TIMERG1.hw_timer[0].config.alarm_en = 1;
+    }
     if (timer_idx==3) {
-               TIMERG1.int_clr_timers.t1 = 1;
-               TIMERG1.hw_timer[1].update=1;
-               TIMERG1.hw_timer[1].config.alarm_en = 1;
-       }
-//     ets_printf("int %d\n", timer_idx);
+        TIMERG1.int_clr_timers.t1 = 1;
+        TIMERG1.hw_timer[1].update=1;
+        TIMERG1.hw_timer[1].config.alarm_en = 1;
+    }
+//  ets_printf("int %d\n", timer_idx);
 }
 
 
 static void timer_test(int flags) {
-       int x;
-       timer_isr_handle_t inth[4];
-       my_timer_init(TIMER_GROUP_0, TIMER_0, 110000);
-       my_timer_init(TIMER_GROUP_0, TIMER_1, 120000);
-       my_timer_init(TIMER_GROUP_1, TIMER_0, 130000);
-       my_timer_init(TIMER_GROUP_1, TIMER_1, 140000);
+    int x;
+    timer_isr_handle_t inth[4];
+    my_timer_init(TIMER_GROUP_0, TIMER_0, 110000);
+    my_timer_init(TIMER_GROUP_0, TIMER_1, 120000);
+    my_timer_init(TIMER_GROUP_1, TIMER_0, 130000);
+    my_timer_init(TIMER_GROUP_1, TIMER_1, 140000);
     timer_isr_register(TIMER_GROUP_0, TIMER_0, timer_isr, (void*)0, flags|ESP_INTR_FLAG_INTRDISABLED, &inth[0]);
     timer_isr_register(TIMER_GROUP_0, TIMER_1, timer_isr, (void*)1, flags, &inth[1]);
     timer_isr_register(TIMER_GROUP_1, TIMER_0, timer_isr, (void*)2, flags, &inth[2]);
@@ -96,111 +93,111 @@ static void timer_test(int flags) {
     timer_start(TIMER_GROUP_1, TIMER_0);
     timer_start(TIMER_GROUP_1, TIMER_1);
 
-       for (x=0; x<4; x++) count[x]=0;
-       printf("Interrupts allocated: %d (dis) %d %d %d\n",
-                       esp_intr_get_intno(inth[0]), esp_intr_get_intno(inth[1]),
-                       esp_intr_get_intno(inth[2]), esp_intr_get_intno(inth[3]));
-       printf("Timer values on start: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
-       TEST_ASSERT(count[0]==0);
-       TEST_ASSERT(count[1]!=0);
-       TEST_ASSERT(count[2]!=0);
-       TEST_ASSERT(count[3]!=0);
-
-       printf("Disabling timers 1 and 2...\n");
-       esp_intr_enable(inth[0]);
-       esp_intr_disable(inth[1]);
-       esp_intr_disable(inth[2]);
-       for (x=0; x<4; x++) count[x]=0;
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
-       TEST_ASSERT(count[0]!=0);
-       TEST_ASSERT(count[1]==0);
-       TEST_ASSERT(count[2]==0);
-       TEST_ASSERT(count[3]!=0);
-       printf("Disabling other half...\n");
-       esp_intr_enable(inth[1]);
-       esp_intr_enable(inth[2]);
-       esp_intr_disable(inth[0]);
-       esp_intr_disable(inth[3]);
-       for (x=0; x<4; x++) count[x]=0;
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
-       TEST_ASSERT(count[0]==0);
-       TEST_ASSERT(count[1]!=0);
-       TEST_ASSERT(count[2]!=0);
-       TEST_ASSERT(count[3]==0);
-       printf("Done.\n");
-       esp_intr_free(inth[0]);
-       esp_intr_free(inth[1]);
-       esp_intr_free(inth[2]);
-       esp_intr_free(inth[3]);
+    for (x=0; x<4; x++) count[x]=0;
+    printf("Interrupts allocated: %d (dis) %d %d %d\n",
+            esp_intr_get_intno(inth[0]), esp_intr_get_intno(inth[1]),
+            esp_intr_get_intno(inth[2]), esp_intr_get_intno(inth[3]));
+    printf("Timer values on start: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
+    TEST_ASSERT(count[0]==0);
+    TEST_ASSERT(count[1]!=0);
+    TEST_ASSERT(count[2]!=0);
+    TEST_ASSERT(count[3]!=0);
+
+    printf("Disabling timers 1 and 2...\n");
+    esp_intr_enable(inth[0]);
+    esp_intr_disable(inth[1]);
+    esp_intr_disable(inth[2]);
+    for (x=0; x<4; x++) count[x]=0;
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
+    TEST_ASSERT(count[0]!=0);
+    TEST_ASSERT(count[1]==0);
+    TEST_ASSERT(count[2]==0);
+    TEST_ASSERT(count[3]!=0);
+    printf("Disabling other half...\n");
+    esp_intr_enable(inth[1]);
+    esp_intr_enable(inth[2]);
+    esp_intr_disable(inth[0]);
+    esp_intr_disable(inth[3]);
+    for (x=0; x<4; x++) count[x]=0;
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
+    TEST_ASSERT(count[0]==0);
+    TEST_ASSERT(count[1]!=0);
+    TEST_ASSERT(count[2]!=0);
+    TEST_ASSERT(count[3]==0);
+    printf("Done.\n");
+    esp_intr_free(inth[0]);
+    esp_intr_free(inth[1]);
+    esp_intr_free(inth[2]);
+    esp_intr_free(inth[3]);
 }
 
 static volatile int int_timer_ctr;
 
 
 void int_timer_handler(void *arg) {
-       xthal_set_ccompare(1, xthal_get_ccount()+8000000);
-       int_timer_ctr++;
+    xthal_set_ccompare(1, xthal_get_ccount()+8000000);
+    int_timer_ctr++;
 }
 
 void local_timer_test()
 {
-       intr_handle_t ih;
-       esp_err_t r;
-       r=esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, 0, int_timer_handler, NULL, &ih);
-       TEST_ASSERT(r==ESP_OK);
-       printf("Int timer 1 intno %d\n", esp_intr_get_intno(ih));
-       xthal_set_ccompare(1, xthal_get_ccount()+8000000);
-       int_timer_ctr=0;
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer val after 1 sec: %d\n", int_timer_ctr);
-       TEST_ASSERT(int_timer_ctr!=0);
-       printf("Disabling int\n");
-       esp_intr_disable(ih);
-       int_timer_ctr=0;
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer val after 1 sec: %d\n", int_timer_ctr);
-       TEST_ASSERT(int_timer_ctr==0);
-       printf("Re-enabling\n");
-       esp_intr_enable(ih);
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer val after 1 sec: %d\n", int_timer_ctr);
-       TEST_ASSERT(int_timer_ctr!=0);
-
-       printf("Free int, re-alloc disabled\n");
-       r=esp_intr_free(ih);
-       TEST_ASSERT(r==ESP_OK);
-       r=esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, ESP_INTR_FLAG_INTRDISABLED, int_timer_handler, NULL, &ih);
-       TEST_ASSERT(r==ESP_OK);
-       int_timer_ctr=0;
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer val after 1 sec: %d\n", int_timer_ctr);
-       TEST_ASSERT(int_timer_ctr==0);
-       printf("Re-enabling\n");
-       esp_intr_enable(ih);
-       vTaskDelay(1000 / portTICK_RATE_MS);
-       printf("Timer val after 1 sec: %d\n", int_timer_ctr);
-       TEST_ASSERT(int_timer_ctr!=0);
-       r=esp_intr_free(ih);
-       TEST_ASSERT(r==ESP_OK);
-       printf("Done.\n");
+    intr_handle_t ih;
+    esp_err_t r;
+    r=esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, 0, int_timer_handler, NULL, &ih);
+    TEST_ASSERT(r==ESP_OK);
+    printf("Int timer 1 intno %d\n", esp_intr_get_intno(ih));
+    xthal_set_ccompare(1, xthal_get_ccount()+8000000);
+    int_timer_ctr=0;
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer val after 1 sec: %d\n", int_timer_ctr);
+    TEST_ASSERT(int_timer_ctr!=0);
+    printf("Disabling int\n");
+    esp_intr_disable(ih);
+    int_timer_ctr=0;
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer val after 1 sec: %d\n", int_timer_ctr);
+    TEST_ASSERT(int_timer_ctr==0);
+    printf("Re-enabling\n");
+    esp_intr_enable(ih);
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer val after 1 sec: %d\n", int_timer_ctr);
+    TEST_ASSERT(int_timer_ctr!=0);
+
+    printf("Free int, re-alloc disabled\n");
+    r=esp_intr_free(ih);
+    TEST_ASSERT(r==ESP_OK);
+    r=esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, ESP_INTR_FLAG_INTRDISABLED, int_timer_handler, NULL, &ih);
+    TEST_ASSERT(r==ESP_OK);
+    int_timer_ctr=0;
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer val after 1 sec: %d\n", int_timer_ctr);
+    TEST_ASSERT(int_timer_ctr==0);
+    printf("Re-enabling\n");
+    esp_intr_enable(ih);
+    vTaskDelay(1000 / portTICK_RATE_MS);
+    printf("Timer val after 1 sec: %d\n", int_timer_ctr);
+    TEST_ASSERT(int_timer_ctr!=0);
+    r=esp_intr_free(ih);
+    TEST_ASSERT(r==ESP_OK);
+    printf("Done.\n");
 }
 
 
 TEST_CASE("Intr_alloc test, CPU-local int source", "[esp32]")
 {
-       local_timer_test();
+    local_timer_test();
 }
 
 TEST_CASE("Intr_alloc test, private ints", "[esp32]")
 {
-       timer_test(0);
+    timer_test(0);
 }
 
 TEST_CASE("Intr_alloc test, shared ints", "[esp32]")
 {
-       timer_test(ESP_INTR_FLAG_SHARED);
+    timer_test(ESP_INTR_FLAG_SHARED);
 }
index e91efe767def095abdf460bb5644cbd2f9cc34b6..f61f39b2c58cc97590fa99f08f41fae5a4763835 100644 (file)
@@ -86,7 +86,9 @@ void IRAM_ATTR timer_group0_isr(void *para)
         /*Timer0 is an example that don't reload counter value*/
         TIMERG0.hw_timer[timer_idx].update = 1;
 
-        /*We don't call a API here because they are not declared with IRAM_ATTR*/
+        /* We don't call a API here because they are not declared with IRAM_ATTR.
+           If we're okay with the timer irq not being serviced while SPI flash cache is disabled,
+           we can alloc this interrupt without the ESP_INTR_FLAG_IRAM flag and use the normal API. */
         TIMERG0.int_clr_timers.t0 = 1;
         uint64_t timer_val = ((uint64_t) TIMERG0.hw_timer[timer_idx].cnt_high) << 32
             | TIMERG0.hw_timer[timer_idx].cnt_low;
@@ -155,7 +157,7 @@ void tg0_timer0_init()
     /*Enable timer interrupt*/
     timer_enable_intr(timer_group, timer_idx);
     /*Set ISR handler*/
-    timer_isr_register(timer_group, timer_idx, timer_group0_isr, (void*) timer_idx, 0);
+    timer_isr_register(timer_group, timer_idx, timer_group0_isr, (void*) timer_idx, ESP_INTR_FLAG_IRAM);
     /*Start timer counter*/
     timer_start(timer_group, timer_idx);
 }
@@ -185,7 +187,7 @@ void tg0_timer1_init()
     /*Enable timer interrupt*/
     timer_enable_intr(timer_group, timer_idx);
     /*Set ISR handler*/
-    timer_isr_register(timer_group, timer_idx, timer_group0_isr, (void*) timer_idx, 0);
+    timer_isr_register(timer_group, timer_idx, timer_group0_isr, (void*) timer_idx, ESP_INTR_FLAG_IRAM);
     /*Start timer counter*/
     timer_start(timer_group, timer_idx);
 }