Strange ATTiny85 behaviour

After a fair bit of searching I'm still at a loss as to why I'm seeing this, but I'd swear my ATTiny85's are running faster at "1MHz" than at "8MHz".

I'm using an Olimex STK500v2 programmer, writing code in Arduino 1.0, and everything is working great. My first project is a mood-light, because RGB LEDs are cool, but of course ATTiny85 only has 2 PWM pins so I fake PWM the third color. When I "burn" the 8MHz-internal-oscillator bootloader and upload the program, it appears to be very choppy and running much slower than if I do the same with the 1MHz-internal-oscillator bootloader.

Any ideas why this is so?

If it helps at all, here's the programmer I added to programmers.txt:

olimexisp.name=AVR ISP 500 Olimex olimexisp.communication=serial olimexisp.protocol=stk500v2

...and here are the board definitions I added to the tiny's boards.txt:

attiny85at8oli.name=ATtiny85 @ 8 MHz (Olimex, internal oscillator; BOD disabled) attiny85at8oli.upload.using=olimexisp attiny85at8oli.upload.maximum_size=8192 attiny85at8oli.bootloader.low_fuses=0xE2 attiny85at8oli.bootloader.high_fuses=0xD7 attiny85at8oli.bootloader.extended_fuses=0xFF attiny85at8oli.bootloader.path=empty attiny85at8oli.bootloader.file=empty85at8.hex attiny85at8oli.build.mcu=attiny85 attiny85at8oli.build.f_cpu=8000000L attiny85at8oli.build.core=tiny

attiny85at1oli.name=ATtiny85 @ 1 MHz (Olimex, internal oscillator; BOD disabled) attiny85at1oli.upload.using=olimexisp attiny85at1oli.upload.maximum_size=8192 attiny85at1oli.bootloader.low_fuses=0x62 attiny85at1oli.bootloader.high_fuses=0xD7 attiny85at1oli.bootloader.extended_fuses=0xFF attiny85at1oli.bootloader.path=empty attiny85at1oli.bootloader.file=empty85at1.hex attiny85at1oli.build.mcu=attiny85 attiny85at1oli.build.f_cpu=1000000L attiny85at1oli.build.core=tiny

Thanks in advance for any help!

(deleted)

just a theory but maybe its running way too fast and glitching

Hi,

What's strange is the info I've used states that the ATtiny85 (and ATtiny45) has 4x PWM capable pins (legs 5 & 6, and either 3 or 4) where pins 3 & 4 share the same timer internally. I created a flickering flame from 3 randomly PWM'd legs and a yellow, orange and red LED based on that, and it appeared to work.

Just wondering if you need to 'fake' PWM at all...or if my flame was a fluke? I'm inspired to breadboard that up again now...

Geoff

ATTiny85 only has 2 PWM pins

It has [u]three[/u] generally useful PWM pins (the fourth is inverted which makes it not-very-Arduinoish).

Argh! Ninja'd by strykeroz.

It has three generally useful PWM pins (the fourth is inverted which makes it not-very-Arduinoish).

Looks like you're right, and I shouldn't trust google-image results without consulting a proper datasheet...

just a theory but maybe its running way too fast and glitching

is this a problem seen in the microcontroller world? even if I'm running at a documented clock-speed?

and finally, after tooling around a bit more today, I think what I'm seeing is the expected result. I didn't know how to fuse the attiny85 to run at 8MHz at first, so the code was originally written for the 1MHz speed. So when I run the same code at 8MHz I'm seeing a beat-frequency, not a flicker.

matt16060936: is this a problem seen in the microcontroller world?

Only if you are running the processor outside the electrical specifications.

So when I run the same code at 8MHz I'm seeing a beat-frequency, not a flicker.

That seems suspiciously like a bug.

bug is what I am getting at, at 1 mhz it appears to work fine, at 8 times that speed its too fast for you to notice then you happen to catch it when you blink or something

My attiny 2313 is doing the same thing. I have a beeper beeping every 300ms and it beeps faster when I have the mcu running at 1mhz than 4 or 8. I'm confused.

How are you running it at 4 MHz?

I set it to 4 mhz then 8 and the beeping was much slower. I'm really new to programming attinys. I just got it going today with my Linux machine and Eclipse after a long battle of trying many different things.

how are you clocking it, externally or internally?

with the internal oscillator you really only have a couple of choices, 8mhz or 8 mhz / 8 (1 mhz)

if your using internal clocking whats your fuse settings?

I have never seen this behavior before and I use 85's all the time

It's an internal clock. I'm new to the tiny stuff. I've got some experience coding Arduinos, but this code structure is very different. I'm currently trying to figure out how to do an analogue read from a DDRD=0X00 input. I'll have to look around the net to find a site that list all the libraries and some code instructions for my attiny2313.

I’ve been playing around with the ATtiny85 and have not seen an issue using the internal Osc… however, not only is “boards” changes required, but you need to have a variant folder for pin_arduino.h

Get both files from MIT:

  • Ray