Skip to content

Make waveform generator a NMI to run always, increase accuracy #5578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 11, 2019
Merged
Next Next commit
Make waveform generator a NMI to run always
Make the waveform generator an NMI using the same code as in 2.4.0.
Making it NMI will ensure it runs even when interrupts are disabled.

Fixes #5568
  • Loading branch information
earlephilhower committed Jan 3, 2019
commit c43b321d9ca76a27cdbe80a08d0000dfbc0d2c7b
7 changes: 4 additions & 3 deletions cores/esp8266/core_esp8266_waveform.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/

#include <Arduino.h>
#include "ets_sys.h"
#include "core_esp8266_waveform.h"

// Need speed, not size, here
Expand Down Expand Up @@ -130,15 +131,15 @@ static uint32_t lastCycleCount = 0; // Last ESP cycle counter on running the int

static void initTimer() {
timer1_disable();
timer1_isr_init();
timer1_attachInterrupt(timer1Interrupt);
ETS_FRC_TIMER1_INTR_ATTACH(NULL, NULL);
ETS_FRC_TIMER1_NMI_INTR_ATTACH(timer1Interrupt);
lastCycleCount = GetCycleCount();
timer1_enable(TIM_DIV1, TIM_EDGE, TIM_SINGLE);
timerRunning = true;
}

static void ICACHE_RAM_ATTR deinitTimer() {
timer1_attachInterrupt(NULL);
ETS_FRC_TIMER1_NMI_INTR_ATTACH(NULL);
timer1_disable();
timer1_isr_init();
timerRunning = false;
Expand Down