ATtiny85 running really slow

I have done this a millions with several identical chips - not sure why I'm having this issue now.

I am programming an ATtiny85 on a stand-alone board (literally nothing on it now - just the chip). My sketch (sending data serially to a device) - when viewed through a scope - is running too slow.

If I just run the following code:

  while (1) {
    noInterrupts();
    digitalWrite(4, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(4, LOW);
    interrupts();
  }

The "highs" go high for 32uS, and the "lows" go low for 8.2uS.

I set the IDE to run w/ 8MHz internal crystal. When I set it to 1MHz Internal, those numbers go to 64uS abd 66us, respectively.

So it looks like clock is getting applied correctly? And I have no "delay" lines, so it shouldn't be a matter of some delay function doing the wrong math.

I need to get level times in the order of 100's of nS. Don't know why I can't do this all of the sudden...

Does the same problem occur if you upload that same code to one of those identical chips that were working as expected?

Have you changed to using a different version of Arduino AVR Boards, either by updating the Arduino IDE or by updating Arduino AVR Boards via Boards Manager?

Have you changed to using a different version of whatever hardware package you're using to add support for ATtiny85?

I had done this with ALL the SAME tools as before. I even started with the exact same code/sketches as before.

I can't try one of my old boards/chips because I can't find them :open_mouth: - though they're all from the same sleeve of chips

Just a wild guess: Try doing a Tools > Burn Bootloader to make sure the fuses are set correctly.

I've done that several times - to try different clock settings and make sure they were applied.

Output is enclosed follows. Thanks for the help!

(I can't tell if this is from one or two different commands?)

avr.txt (16.5 KB)

digitalWrite is slow. That sounds about right to me.

If you need the speed, you need to do direct port writes.

What DRAZZY Said. A digitalWrite loop on an arduino goes about 150 to 200kHz on a 16MHz chip, which is about 5us per state. For you to be at abou 8us on an 8MHz machine seems OK.

Yep - you're both right - I went do direct ports and everything looks good. I was comparing with the wrong old code. Thanks!