Skip to content

Re-implement PWM generator logic #7231

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 68 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
2c010d6
Re-implement PWM generator logic
earlephilhower Apr 19, 2020
122ca23
Merge branch 'master' into realpwm
earlephilhower Apr 19, 2020
118103b
Adjust running PWM when analogWriteFreq changed
earlephilhower Apr 19, 2020
5cd145e
Also preserve phase of running tone/waveforms
earlephilhower Apr 19, 2020
4ce623d
Clean up signed/unsigned mismatch, 160MHz operat'n
earlephilhower Apr 19, 2020
3a6f6c1
Turn off PWM on a Tone or digitalWrite
earlephilhower Apr 20, 2020
27ee6f8
Remove hump due to fixed IRQ delta
earlephilhower Apr 21, 2020
5faf6be
Speed PWM generator by reordering data struct
earlephilhower Apr 22, 2020
94af195
Remove if() that could never evaluate TRUE
earlephilhower Apr 24, 2020
1182cd0
Add error feedback to waveform generation
earlephilhower Apr 27, 2020
7ee7d19
Move _stopPWM and _removePWMEntry to IRAM
earlephilhower Apr 27, 2020
c12e961
Avoid long wait times when PWM freq is low
earlephilhower Apr 27, 2020
143b6ae
Merge branch 'master' into realpwm
earlephilhower Apr 28, 2020
a783621
Fix bug where tone/pwm could happen on same pin
earlephilhower Apr 28, 2020
ad3076c
Adjust for random 160MHZ operation
earlephilhower Apr 28, 2020
dc32961
Clean up leftover debugs in ISR
earlephilhower Apr 28, 2020
ec62ee3
Subtract constant-time overhead for PWM, add 60khz
earlephilhower Apr 28, 2020
a41890b
Fix GPIO16 not toggling properly.
earlephilhower Apr 28, 2020
42bbede
Remove constant offset to PWM period
earlephilhower Apr 29, 2020
79a7f7d
Remove volatiles, replace with explicit membarrier
earlephilhower Apr 29, 2020
cbff7a3
Consolidate data into single structure
earlephilhower Apr 29, 2020
4196bf8
Factor out common timer shutdown code
earlephilhower Apr 29, 2020
14f4416
Remove unneeded extra copy on PWM start
earlephilhower Apr 29, 2020
2002a5d
Factor out common edge work in waveform loop
earlephilhower Apr 29, 2020
5b1f288
Factor out waveform phase feedback loop math
earlephilhower Apr 29, 2020
f42696c
Reduce PWM size by using 32b count, indexes
earlephilhower Apr 29, 2020
2b0dde4
GP16O is a 1-bit register, just write to it
earlephilhower Apr 29, 2020
b0e818f
Merge branch 'master' into realpwm
earlephilhower Apr 29, 2020
dfaa9ce
Increase PWM linearity in low/high regions
earlephilhower May 3, 2020
3909ada
Remove redundant GetCycleCount (non-IRQ)
earlephilhower May 3, 2020
413cd17
Factor out common timer setup operations
earlephilhower May 3, 2020
07f5ff1
Fix clean-waveform transition, lock to tone faster
earlephilhower May 3, 2020
539d0d4
Reduce code size ~145 bytes
earlephilhower May 4, 2020
df51b21
Reduce IRAM by pushing more work to _setPWM
earlephilhower May 4, 2020
867b181
Fix typo in PWM pin 1->0 transition
earlephilhower May 5, 2020
f757778
Combine cleanup and pin remove, save 50 bytes IROM
earlephilhower May 5, 2020
9424090
Remove unused analogMap, toneMap
earlephilhower May 5, 2020
c8b53ef
Save IRAM/heap by adjusting WVF update struct
earlephilhower May 5, 2020
e6b7aa1
Don't duplicate PWM period calculation
earlephilhower May 5, 2020
28645ff
Factor out common PWM update code
earlephilhower May 5, 2020
3ee638c
Merge branch 'master' into realpwm
earlephilhower May 5, 2020
174d19e
Clean up old comments
earlephilhower May 5, 2020
a910eae
Fix indent, remove some unneeded if-else branches
earlephilhower May 5, 2020
179b9d6
Fix regression when analogWrite done cold
earlephilhower May 5, 2020
e44171f
Save 16b of IRAM by not re-setting edge intr bit
earlephilhower May 6, 2020
7fe9a2d
Allow on-the-fly PWM frequency changes
earlephilhower May 7, 2020
e7cb533
Adjust for fixed overhead on PWM period
earlephilhower May 8, 2020
083560d
Fix value reversal when analogWrite out of range
earlephilhower May 8, 2020
e421d81
Merge branch 'master' into realpwm
earlephilhower May 9, 2020
5be4961
Don't optimize the satopWaveform call
earlephilhower May 10, 2020
051008a
Avoid side effects in addPWMtoList
earlephilhower May 13, 2020
6692418
Adjust PWM period as fcn of # of PWM pins
earlephilhower May 18, 2020
606c5cd
Merge branch 'master' into realpwm
earlephilhower Jun 4, 2020
524f047
Fix occasional Tone artifacts
earlephilhower Jun 6, 2020
361d4a2
Reduce CPU usage and enhance low range PWM output
earlephilhower Jun 6, 2020
975fe12
Merge branch 'master' into realpwm
earlephilhower Jun 7, 2020
9e48706
Update min IRQ time to remove humps in PWM linearity
earlephilhower Jun 7, 2020
565f21f
Remove minor bump at high PWM frequencies
earlephilhower Jun 7, 2020
272dc9d
Undo the 160->80 frequency adjust
earlephilhower Jun 8, 2020
8f9af5d
Merge branch 'master' into realpwm
earlephilhower Jul 13, 2020
2961933
Merge branch 'master' into realpwm
earlephilhower Aug 23, 2020
e5afab0
Merge branch 'master' into realpwm
earlephilhower Aug 29, 2020
e5ba217
Update core_esp8266_wiring_pwm.cpp
earlephilhower Aug 29, 2020
f911754
Update core_esp8266_wiring_pwm.cpp
earlephilhower Aug 29, 2020
1b34278
Merge branch 'master' into realpwm
d-a-v Oct 26, 2020
55e8abb
Merge branch 'master' of https://github.com/esp8266/Arduino into realpwm
earlephilhower Nov 20, 2020
4cc3d8a
Fix Servo shutdown changes which caused trouble with Servo::detach()
earlephilhower Nov 20, 2020
a353909
Servo shutdown tweak in PWM path
earlephilhower Nov 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cores/esp8266/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ static void _startTone(uint8_t _pin, uint32_t high, uint32_t low, uint32_t durat
return;
}

// Stop any analogWrites (PWM) because they are a different generator
_stopPWM(_pin);
// If there's another Tone or startWaveform on this pin
// it will be changed on-the-fly (no need to stop it)

pinMode(_pin, OUTPUT);

high = std::max(high, (uint32_t)microsecondsToClockCycles(25)); // new 20KHz maximum tone frequency,
Expand Down
Loading