Here is the function I am using that has the problem (in this instance, group number and timer number are both "0"):
Code: Select all
bool IntervalTimer::beginCycles(timer_isr_t isr_handler, intPeriod Period, bool scale )
{
// Find next available timer
timerID = getNextAvailableTimer();
if(timerID < 0){ return false; }
timerAvailable[timerID] = false; // Claim this timer and make it unavailable
groupNumber = (timer_group_t)getGroup(timerID);
timerNumber = (timer_idx_t)getGroupTimer(timerID);
timer_config_t config = {
.alarm_en = TIMER_ALARM_EN,
.counter_en = TIMER_PAUSE,
.intr_type = TIMER_INTR_LEVEL,
.counter_dir = TIMER_COUNT_UP,
.auto_reload = TIMER_AUTORELOAD_DIS,//MAKE SURE THIS IS DISABLED FOR ACTUAL USE
.divider = 16,
}; // default clock source is APB
timer_init(groupNumber, timerNumber, &config);
// Timer's counter will initially start from value below.
// Also, if auto_reload is set, this value will be automatically reload on alarm
timer_set_counter_value(groupNumber, timerNumber, 0);
// Configure the alarm value and the interrupt on alarm.
if(Period == 833)
{
timer_set_alarm_value(groupNumber, timerNumber, 2085); // 833.33uS or 1200 baud //16div = 2083.2927, 1230uS or 813 baud = 3075
}
else if(Period == 1230)
{
timer_set_alarm_value(groupNumber, timerNumber, 3075); // 1230uS or 813 baud = 3075
}
timer_enable_intr(groupNumber, timerNumber);
timer_isr_callback_add(groupNumber, timerNumber, isr_handler, 0, 0);
timer_start(groupNumber, timerNumber);
return true;
}
Code: Select all
IntervalTimer rxTimer;
rxTimer.begin((timer_isr_t)testISR, 833, uSec);
Code: Select all
bool alternate = true;
void testISR()
{
if(alternate)
{
gpio_set_level((gpio_num_t)5, 1);
alternate = false;
}else{
gpio_set_level((gpio_num_t)5, 0);
alternate = true;
}
}
This was the example I was basing my code off, and they use auto-reload enabled and disabled, so I don't understand why mine does not work:
https://github.com/espressif/esp-idf/bl ... ple_main.c
And this is the exact ESP32 I am using ( ESP32-WROOM-32UE (16MB) )
Any help or advice on this is greatly appreciated, as I am currently stuck on this problem. Thanks!