Skip to content

Issue with tone() on Arduino UNO Wifi #13

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

Closed
lemio opened this issue Jan 16, 2019 · 1 comment
Closed

Issue with tone() on Arduino UNO Wifi #13

lemio opened this issue Jan 16, 2019 · 1 comment

Comments

@lemio
Copy link

lemio commented Jan 16, 2019

This code wouldn't make a sound on a regular piezo, nor make a signal on the oscilloscope

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  delay(1000);
  tone(6,600);
  delay(100);
  noTone(6);
}

While this code does work:

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  tone(6,600);
  delay(100);
  noTone(6);
  delay(1000);
}

This code also works:

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  delay(1000);
  tone(6,600);
  tone(6,600);
  delay(100);
  noTone(6);
}

Would there be a way to fix it in the https://github.com/arduino/ArduinoCore-megaavr/blob/master/cores/arduino/Tone.cpp file? It seems like delay(x) leaves some timer in a state that tone can't deal with. Other functions like delayMicroseconds() seem to work with tone without any problems...

I use version 1.6.24 in the board manager, tried different Arduino UNO Wifi's and selecting ATMEGA328 register emulation doesn't influence the problem.

@facchinm
Copy link
Member

Fixed by 76c9153, it was an issue with registers not being setup due to a missing cli()

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

No branches or pull requests

2 participants