1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00
Earle F. Philhower, III 8a64a1236f
Make waveform generator a NMI to run always, increase accuracy (#5578)
* 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

* Move to a lockless waveform generator

Make the waveform generator lockless by doing all dangerous structure
updates in the interrupt handler.  start/stopWaveform set a flag and
cause an interrupt.  They wait for the interrupt to complete and clear
those flags before returning.

Also rework the Waveform[] array to be lockless.

* Optimize IRAM and CPU usage in IRQ

Try and minimize the IRAM needed to run the IRQ while keeping performance at
or better than before.

* Avoid WDT errors, optimize pin scans

Calculate first and last pins to scan for PWM, significantly increasing
accuracy for pulses under 10us at 80MHz.  Now if you are using a single
PWM channel at 80MHz you can generate a 1.125us pulse (down from ~4us).

Rework the IRQ logic to avoid potential WDT errors.  When at 80MHz it
appears that interrupts occuring faster than 10us apart on the timer
cause WDT errors.  Avoid it by increasing the minimum delay between
IRQs on the timer accordingly.

* Clean up format/comment, remove delay() in stop

stopWaveform may be called from an interrupt (it's called by digitalWrite)
so we can't call delay().  Make it a busy wait for the IRQ to clear the
waveform.

Only set a new timeout of 10us when starting a new waveform when there
is no other event coming sooner than that.

Update formatting and comments per @devyte's requests.

Replace MicrosecondsToCycles() with standard Arduino call.
2019-01-11 15:54:59 -08:00
..
2017-12-08 02:08:54 -03:00
2018-12-15 10:14:30 -08:00
2018-12-15 10:14:30 -08:00
2017-01-31 10:07:59 +03:00
2016-05-20 10:20:04 +08:00
2018-11-20 18:51:45 -02:00
2018-03-09 12:47:22 +08:00
2018-03-09 12:47:22 +08:00
2018-11-24 02:00:34 -03:00
2017-05-12 01:03:14 -05:00
2018-09-10 01:50:01 -03:00
2016-03-03 02:13:22 +03:00
2018-12-10 10:35:11 -03:00
2018-12-10 10:35:11 -03:00
2014-12-01 00:34:28 +03:00
2018-10-23 22:17:54 +02:00
2018-10-23 22:17:54 +02:00