Arduino Tiny

@Codingbadly: just a side note, but this is now my favorite way of developing apps for the Tiny. Excellent work, and wholehearted thanks for sharing. It's really enabled me to make a lot more crazy devices with my tinys without having to resort to AVR studio.

When looking at the tinyX5 core set, there are two timers

Yup.

both of which can drive PWM outputs

Yup.

Only timer0 can do phase correct PWM

Yup. By default, the Tiny Core is configured with two phase correct outputs and one fast output. There is a compile-time option to switch to one phase and two fast.

It looks like the PWM outputs of the two timers overlap

Yup. And I vaguely recall that you can have both outputs enabled creating a rather strange situation. The Tiny Core, however, only enables one of the outputs.

if you want more PWM outputs

I suspect this could be ported to the '85 processor allowing (low frequency) PWM on all the pins...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1268806013

Has anyone else experimented with more PWM channels on the tinyX5 series?

More than what? Two? Three? Four?

The attiny2313 says it has four PWM channels

Yup.

whether some overlap

Nope. Four outputs.

buzzdavidson:
@Codingbadly: just a side note, but this is now my favorite way of developing apps for the Tiny.

Mine, too. :slight_smile:

Excellent work

Thanks. Got some other goodies in the pipe: Arduino ISP version that better supports ISP development. Dramatically improved Tiny Tuner. Addition of fast*Digital. Support for ATtiny13 and ATtiny4313. But, work is getting in the way.

and wholehearted thanks for sharing

You are quite welcome. And, if you're interested, I suspect we can find a way for you to give back. :wink:

It's really enabled me to make a lot more crazy devices with my tinys without having to resort to AVR studio

Don't be shy...
http://arduino.cc/forum/index.php/board,29.0.html

Sharing a tip.

Using the Arduino ISP programmer I got the annoying messages from avrdude asking to define PAGEL and BS2. Since the ATtinyX5 family doesn't have these pins, and I guess we don't actually need them, I defined them in AVRDUDE.CONF to be pins/ports that don't exist - no more error messages.

# PAGEL and BS2 defined by --RL so we don't get a warning error from avrdude n/a on attiny85
    pagel            = 0xD0;  # these don't exist on the ATtinyX5 series
    bs2              = 0xD1;  # these don't exist on the ATtinyX5 series

You can find AVRDUDE.CONF in

arduino-0022\hardware\tools\avr\etc

hi,

i trying to get my attiny85 to run at 8mhz. but i cant get it to work..

when i upload the blink sketch at 1mhz it will blink like it is supposed to. but when i upload it at 8mhz it will blink much slower. so i assume the attiny thinks it is running at 8mhz but it is actually running at 1mhz..

i read somewhere in this threat that you need to set the fuse buts by burning the bootloader. but this is not working for me, when i do i get this error message

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avr_read(): error reading address 0x0000
    read operation not supported for memory "lock"
avrdude: failed to read all of lock memory, rc=-2

i am using the arduino as a isp programmer..

The PAGEL and BS2 warnings can be ignored.

Close the Arduino IDE.

Locate and open the avrdude.conf file. It should be located in the {Arduino}\hardware\tools\avr\etc folder.

Make a backup copy of the avrdude.conf file.

Find the ATtiny85 section. It starts with this...

#------------------------------------------------------------
# ATtiny85
#------------------------------------------------------------

Locate the memory lock section. It looks like it starts 134 lines below the start of the ATtiny85 section.

Add "read" data...

     memory "lock"
         size            = 1;
         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
                           "x x x x  x x x x  1 1 i i  i i i i";
         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
                           "0 0 0 0  0 0 0 0  o o o o  o o o o";
        min_write_delay = 9000;
        max_write_delay = 9000;
       ;

Save and close the avrdude.conf file.

Try again.

thanks! now it works (-:

there were 2 of these files: avrdude.conf.bak and avrdude.conf
so i changed both.

maybe its good to include this in the readme.txt

Excellent. I'm glad you have it working.

This is a good place to make suggestions...
http://code.google.com/p/arduino-tiny/issues/list

I've already added an entry...
http://code.google.com/p/arduino-tiny/issues/detail?id=12

Sometimes ago, while searching info about Attiny and RGB Leds, I found this code which does PWM software on 3 pin with the timer0.
I don't remember where I found this code and the author did not write his name on it.

Maybe It could help to create a small lib to handle rgb leds.

attiny85_rgb_led.c (2.97 KB)

I think Coding Badly's core enables all three PWM outputs by default, two on timer0 and one on timer1. Unless of course you start editing config files and swapping what is where.

@Coding Badly what about the incoming structural changes in the arduino ide?
i mean the arduino.h instead of wprogram.h and the external pins file etc....
We are building a "large family" arduino ide called ArduOpen ( a kind of arduino on steroids) and we would like to include your core, beside the arduino-extras and the original one, so we need to know what you are planning to do.

BrainBooster:
@Coding Badly what about the incoming structural changes in the arduino ide? i mean the arduino.h instead of wprogram.h and the external pins file etc....

I've been following progress on the Developer's List. From what I can tell, the only required change is to rename "WProgram.h" to "Arduino.h".

We are building a "large family" arduino ide called ArduOpen ( a kind of arduino on steroids) and we would like to include your core, beside the arduino-extras and the original one, so we need to know what you are planning to do.

Sounds good.

My policy is to deliver an update as soon as possible after a release of the Arduino IDE. I believe the Arduino crew is targeting Sep 15. Usually, I perform a complete review and, when possible, ensure the Tiny Core is "highly compatible". This time around I probably won't have time to do that until mid-October. So, just after the Arduino 1.0 release, I plan to make just enough changes so the Tiny Core, as it is now, can be used with the new IDE.

But, work has a bad habit of getting in the way.

..and about the extetnal pins configuration file?
can i try to patch myself the core files, just to see if it can work in the new ide?

BrainBooster:
..and about the extetnal pins configuration file?

The intent is to make it easier to port the Standard Core to other processors. Unfortunately, the idea falls considerably short with the Tiny processors. In the short term, I intend to mostly ignore / workaround the feature.

can i try to patch myself the core files, just to see if it can work in the new ide?

Please do. And please let me know how you progress or if you get stuck.

ok thank you.
it will be done :slight_smile: asap

@Coding Badly i did the 1st experiment with arduino 1 beta 3 and the modded arduinotiny and i succeded in compile the blink example for the attiny85 at 1mhz as selected board XD.
i'm not at home now so i can't try to upload the sketch, but i would say that a big step has been done :slight_smile:
i'm planning to allot some time in the weekend to do further tests...
stay tuned

Rick Kimball:
For using Arduino as ISP, I need to disable Auto Reset capabilities. Therefore I inserted 110 ohms (330 ohms / 3) resistor between Reset-pin and 5V-pin. This resistor should be above 110 ohms and below 124 in accordance with this document: DisablingAutoResetOnSerialConnection.

Is it correct that this resistor goes between +5V (from Arduino pin with 5V) and reset pin on ATTiny?

(deleted)

Hello.
I'm writing a library that utilizes timers and is portable on several micros.
My library doesn't work with Attiny84. I am not able to make ISRs routines work, nor with INT0/Timer0 or INT1/Timer1.
This is the issue that I've opened yesterday on Tiny Core site.
http://code.google.com/p/arduino-tiny/issues/detail?id=19

To replicate the problem simply get a Tiny84, put it on a breadboard with a R+LED on digital pin 0 (phisical pin #2) and compile and upload the following code:

int counterT=0;
int starterT=0;
byte state=1;
#define LED 0

void setupTimer() {
    float prescaler;

    //during setup, disable all the interrupts based on timer 0
    TIMSK0 &= ~(1<<TOIE0);
    TIMSK0 &= ~((1<<OCIE0A) | (1<<OCIE0B));
    //normal mode: increment counter until overflow
    TCCR0B &= ~(1<<WGM02);
    TCCR0A &= ~((1<<WGM01) | (1<<WGM00));
    //normal mode: no pwm generation
    TCCR0A &= ~((1<<COM0A0) | (1<<COM0A1));
    TCCR0A &= ~((1<<COM0B0) | (1<<COM0B1));
    //the following code sets the prescaler depending on the system clock
    if ((F_CPU == 16000000UL) || (F_CPU == 8000000UL)) {   // prescaler set to 64
        TCCR0B &= ~(1<<CS02);
        TCCR0B |= ((1<<CS01) | (1<<CS00));
        prescaler = 64.0;
    } else if (F_CPU == 1000000UL) { // prescaler set to 8
	TCCR0B &= ~((1<<CS02) | (1<<CS00));
	TCCR0B |= (1<<CS01);
	prescaler = 8.0;
    }
    starterT = 256 - (int)((float)F_CPU * 0.001 / prescaler);

    TCNT0 = starterT;
    TIMSK0 |= (1<<TOIE0);
}

ISR(TIMER0_OVF_vect) {
    TCNT0 = starterT;
    counterT++;
    if (counterT>999) { 
        state ^=1; 
        counterT=0;
        digitalWrite(LED, state);
    }
}

void setup() {
    pinMode(LED, OUTPUT);
    digitalWrite(LED, state);
    setupTimer();
}

void loop() {
}

The led lights up forever.

ISR(TIMER0_OVF_vect) {

ISR(TIM0_OVF_vect) {