Skip to content
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

Waveform stopped by runtime limit in iSR doesn't deinit the timer #7236

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

dok-net
Copy link
Contributor

@dok-net dok-net commented Apr 21, 2020

But stopWaveform() refuses to do anything about it if the waveform was previously stopped by expired runtime from inside ISR, either. Fix for #7230 from original issue reporter.

For some reason stopWaveform() is in IRAM cache and optimized for performance over size.
Also, stopWaveform() would be explicitly called (if indirectly) from user code, which for waveform with a runtime argument can be reasonably expected to be well adjusted in time to avoid race conditions between ISR-based cutoff vs. stopWaveform().

Both facts talk back to #7232 (comment), which curiously mentions that 10µs isn't a big thing - for a function that bloats under gcc -O2 and is in IRAM cache :-)

while (waveformToDisable) {
/* no-op */ // Can't delay() since stopWaveform may be called from an IRQ
if (waveformsEnabled & (1UL << pin)) {
waveformToDisable = 1UL << pin;
Copy link
Contributor Author

@dok-net dok-net Apr 21, 2020

Choose a reason for hiding this comment

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

Everyone can read 1UL << pin, absolutely no need to introduce an object "mask" for this idiom. Use constness if you really feel the need to.

Copy link
Collaborator

@earlephilhower earlephilhower Apr 21, 2020

Choose a reason for hiding this comment

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

Removing a named variable like this, used immediately after definition in the code, is not going to affect GCC's generated code unless it's got a really bad hangover. It's for readability by the next maintainer, only.

…t stopWaveform refuses to do anything if the waveform was stopped by runtime, either. Fixes esp8266#7230.
Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

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

stopWaveform is in IRAM because it's possible to turn off a waveform via a digitalWrite/etc. from inside an IRQ.

If you are concerned about generated code size, you should move this out of the O2 code block.

Please note that O2 does not always generate larger code and you'd want to try both ways and then pick the smallest.

OTW, I'm fine w/this PR and moving the delay into the if-clause.

while (waveformToDisable) {
/* no-op */ // Can't delay() since stopWaveform may be called from an IRQ
if (waveformsEnabled & (1UL << pin)) {
waveformToDisable = 1UL << pin;
Copy link
Collaborator

@earlephilhower earlephilhower Apr 21, 2020

Choose a reason for hiding this comment

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

Removing a named variable like this, used immediately after definition in the code, is not going to affect GCC's generated code unless it's got a really bad hangover. It's for readability by the next maintainer, only.

@earlephilhower earlephilhower added this to the 2.7.0 milestone Apr 21, 2020
@earlephilhower earlephilhower merged commit 36e047e into esp8266:master Apr 23, 2020
@dok-net dok-net deleted the fix_7230 branch April 23, 2020 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants