Skip to content

Commit 2bec027

Browse files
committed
move interrupt handler to iram
1 parent c4917cd commit 2bec027

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ports/esp32s2/common-hal/frequencyio/FrequencyIn.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
#include "common-hal/microcontroller/Pin.h"
3737

38-
static void frequencyin_interrupt_handler(void *self_in) {
38+
static void IRAM_ATTR frequencyin_interrupt_handler(void *self_in) {
3939
frequencyio_frequencyin_obj_t* self = self_in;
4040
// get counter value
4141
int16_t count;
@@ -44,6 +44,10 @@ static void frequencyin_interrupt_handler(void *self_in) {
4444

4545
// reset counter
4646
pcnt_counter_clear(self->unit);
47+
48+
// reset interrupt
49+
TIMERG0.int_clr.t0 = 1;
50+
TIMERG0.hw_timer[0].config.alarm_en = 1;
4751
}
4852

4953
static void init_timer(frequencyio_frequencyin_obj_t* self, uint16_t capture_period) {
@@ -62,7 +66,7 @@ static void init_timer(frequencyio_frequencyin_obj_t* self, uint16_t capture_per
6266
timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0);
6367
timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, capture_period * 1000000);
6468
timer_enable_intr(TIMER_GROUP_0, TIMER_0);
65-
timer_isr_register(TIMER_GROUP_0, TIMER_0, &frequencyin_interrupt_handler, (void *)self, 0, &self->handle);
69+
timer_isr_register(TIMER_GROUP_0, TIMER_0, frequencyin_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle);
6670

6771
// Start timer
6872
timer_start(TIMER_GROUP_0, TIMER_0);

0 commit comments

Comments
 (0)