mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-11 13:00:19 +00:00
timer_group: fix intr_enable
timer group interrupt enable is controled by level_int_ena instead of int_ena Closes https://github.com/espressif/esp-idf/issues/5103
This commit is contained in:
@@ -42,7 +42,7 @@ xQueueHandle timer_queue;
|
||||
static void inline print_timer_counter(uint64_t counter_value)
|
||||
{
|
||||
printf("Counter: 0x%08x%08x\n", (uint32_t) (counter_value >> 32),
|
||||
(uint32_t) (counter_value));
|
||||
(uint32_t) (counter_value));
|
||||
printf("Time : %.8f s\n", (double) counter_value / TIMER_SCALE);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void IRAM_ATTR timer_group0_isr(void *para)
|
||||
from the timer that reported the interrupt */
|
||||
uint32_t intr_status = TIMERG0.int_st_timers.val;
|
||||
TIMERG0.hw_timer[timer_idx].update = 1;
|
||||
uint64_t timer_counter_value =
|
||||
uint64_t timer_counter_value =
|
||||
((uint64_t) TIMERG0.hw_timer[timer_idx].cnt_high) << 32
|
||||
| TIMERG0.hw_timer[timer_idx].cnt_low;
|
||||
|
||||
@@ -103,17 +103,17 @@ void IRAM_ATTR timer_group0_isr(void *para)
|
||||
* auto_reload - should the timer auto reload on alarm?
|
||||
* timer_interval_sec - the interval of alarm to set
|
||||
*/
|
||||
static void example_tg0_timer_init(int timer_idx,
|
||||
bool auto_reload, double timer_interval_sec)
|
||||
static void example_tg0_timer_init(int timer_idx,
|
||||
bool auto_reload, double timer_interval_sec)
|
||||
{
|
||||
/* Select and initialize basic parameters of the timer */
|
||||
timer_config_t config;
|
||||
config.divider = TIMER_DIVIDER;
|
||||
config.counter_dir = TIMER_COUNT_UP;
|
||||
config.counter_en = TIMER_PAUSE;
|
||||
config.alarm_en = TIMER_ALARM_EN;
|
||||
config.intr_type = TIMER_INTR_LEVEL;
|
||||
config.auto_reload = auto_reload;
|
||||
timer_config_t config = {
|
||||
.divider = TIMER_DIVIDER,
|
||||
.counter_dir = TIMER_COUNT_UP,
|
||||
.counter_en = TIMER_PAUSE,
|
||||
.alarm_en = TIMER_ALARM_EN,
|
||||
.auto_reload = auto_reload,
|
||||
}; // default clock source is APB
|
||||
timer_init(TIMER_GROUP_0, timer_idx, &config);
|
||||
|
||||
/* Timer's counter will initially start from value below.
|
||||
@@ -123,8 +123,8 @@ static void example_tg0_timer_init(int timer_idx,
|
||||
/* Configure the alarm value and the interrupt on alarm. */
|
||||
timer_set_alarm_value(TIMER_GROUP_0, timer_idx, timer_interval_sec * TIMER_SCALE);
|
||||
timer_enable_intr(TIMER_GROUP_0, timer_idx);
|
||||
timer_isr_register(TIMER_GROUP_0, timer_idx, timer_group0_isr,
|
||||
(void *) timer_idx, ESP_INTR_FLAG_IRAM, NULL);
|
||||
timer_isr_register(TIMER_GROUP_0, timer_idx, timer_group0_isr,
|
||||
(void *) timer_idx, ESP_INTR_FLAG_IRAM, NULL);
|
||||
|
||||
timer_start(TIMER_GROUP_0, timer_idx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user