ATTINY 861 Tone issues observed

Hello everyone,

I have been encountering an odd issue with the TONE() function on the ATTINY861 Micro. This question is mostly directed towards Dr.Azzy as I am utilizing his core, "ATTinyCore V1.2.3" on Arduino 1.8.8. First and foremost, this is the code I tried and is producing my observed results:

const uint8_t out = 8;
void setup() {
  // put your setup code here, to run once:
  pinMode(out, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  tone(out, 15000);
  delay(2000);
}

If I put in the desired frequency as 10000hz I get 2000hz measured on my scope, this is with a Timer 1 clock at 8mhz, at 64mhz the reading is 250hz ~ /8 which makes sense. From what I read I understood that there was a lower hardware limitation around 16hz @ 8mhz F_CPU for the Tone library. As to the upper limit, I thought I read it was well above my 10000hz target. Is this a bug due to the odd timer for this particular core? It would be nice to utilize this approach versus putting together a hardware timer manually.

If anyone has had a similar experience with the tone function, or if it is a known limitation please let me know.

Any input / advice is greatly appreciated.

Thanks,

klotzy_550

I have also tried this on Arduino digital pin 6, which I think is PB3 IIRC, and the preferred hardware solution for the tone library on ATTiny861. Same issues. I have proceeded with writting my own hardware timer setup and have been able to produce waveforms from 5hz to ~10khz quite comfortably after cleaning up and optimizing some code.

That being said I would like to address the issues that I am seeing with Tone() on the ATTiny861.

-Klotzy_550

I think you best open an issue on the ATTinyCore's Github page. This appears to be a bug in that library. The 861 indeed has some unusual timers.