Skip to content

Commit

Permalink
Fix timerBegin for espressif_3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kotovasia5120 committed Jul 29, 2024
1 parent 40cf991 commit be03cd0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions h4/h4.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1039,9 +1039,9 @@ void IRAM_ATTR pulse2Enc() {

void setAsyncTimerEnable(bool value) {
if (value) {
timerAlarmEnable(async_timer);
timerStart(async_timer);
} else {
timerAlarmDisable(async_timer);
timerStop(async_timer);
}
}

Expand Down Expand Up @@ -1862,9 +1862,7 @@ void updateAsyncTimerSettings() {
setDir(getAsyncAxis(), dupr > 0);

// dupr can change while we're in async mode, keep updating timer frequency.
timerAlarmWrite(async_timer, getTimerLimit(), true);
// without this timer stops working if already above new limit
timerWrite(async_timer, 0);
timerAlarm(async_timer, getTimerLimit(), true, 0);
}

void setDupr(long value) {
Expand Down Expand Up @@ -1965,7 +1963,7 @@ void setModeFromLoop(int value) {
if (mode == MODE_ASYNC || mode == MODE_A1) {
if (!timerAttached) {
timerAttached = true;
timerAttachInterrupt(async_timer, &onAsyncTimer, true);
timerAttachInterrupt(async_timer, &onAsyncTimer);
}
updateAsyncTimerSettings();
setAsyncTimerEnable(true);
Expand Down

1 comment on commit be03cd0

@kotovasia5120
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.