Arduino Tiny

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) {

THank you for your replay but it didn't work.
I've already tested your solution but in the IDE terminal I get:

core.a(wiring.c.o): In function 'init':
/home/...(patch).../hardware/tiny/cores/wiring.c:234: multiple definition of '__vector_11'
int_timer0_attiny84.cpp.o:int_timer0_attiny84.cpp:38: first defined here

For the ATtiny84 processor (and family), timer 0 is used by millis, micros, delay, and delayMicroseconds so you will not be able to override the overflow interrupt vector. Timer 1 is initialized for PWM but you are otherwise free to do whatever you want with it.

There are compile-time switches in "core_build_options.h" that may be of interest. If INITIALIZE_SECONDARY_TIMERS is set to 0, timer 1 is left alone. TIMER_TO_USE_FOR_MILLIS (in the ATtiny84 section) can be used to switch millis to timer 1.

If you are building a library specifically for the Tiny Core, the code in "UserTimer.h" (and "core_timers.h") may help.

I've followed your suggestions and now it works. Thanks.

But without any help I wouldn't be able to make my code running. Tiny core is good but the documentation lacks a little bit :sweat_smile: