Skip to content

Tone causes crash with frequency = 0 #2491

Closed
@ghost

Description

It's not uncommon to use tone with frequency = 0 to indicate 'silence/no note'.
Example: https://github.com/arduino/Arduino/blob/master/build/shared/examples/02.Digital/toneMelody/toneMelody.ino
This crashes right now, I expect because of a division in zero in: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Tone.cpp

timer1_write((clockCyclesPerMicrosecond() * 500000) / frequency);
Admittedly the behavior on Arduino for frequency = 0 doesn't seem to be documented, and I expect on some other cores it would also crash or do weird things..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions