Go Down

Topic: Arduino Tiny (Read 66671 times) previous topic - next topic

spycatcher2k

The resistor goes on the arduino, not the chip being programmed.
Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

leo72

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:

Code: [Select]
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.

Coding Badly


Quote
ISR(TIMER0_OVF_vect) {



Quote
ISR(TIM0_OVF_vect) {


leo72

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

Code: [Select]
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


Coding Badly


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.

leo72

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  :smiley-sweat:

Coding Badly


You are welcome.  I'm glad you have it working.

leo72

PS:
I'm working on a multi-micro library. The library will be widely available soon.

leo72

Sorry, one question. What about Arduino IDE 1.0 and Tiny core?
I mean, when the Arduino IDE 1.0 will be released, will the actual Tiny core be compatible with it or should we wait for a Tiny core 1.0?

I'm using Tiny85 and Tiny84 and I would like to know about Tiny core upgrades  ;)

Coding Badly

Quote
Sorry, one question.


No need to apologize.  The point of the forum is to ask questions.

Quote
What about Arduino IDE 1.0 and Tiny core?


I've been tracking, reviewing, and testing against the changes to the Arduino IDE.  As far as I can tell, there is just one change required.  Basically, an "Arduino.h" file has to be added to the core directory that includes "WProgram.h"...
http://code.google.com/p/arduino-tiny/issues/detail?id=21

In general, I will always wait until after the next IDE has been released before releasing a compatible Tiny Core.

Quote
I'm using Tiny85 and Tiny84 and I would like to know about Tiny core upgrades


I have lots of goodies planned for the next release.  The work is progressing nicely.  Unfortunately, it may be a few weeks before its ready.

  ? Variation of the digital*Fast functions designed to minimize the Flash consumed
  ? Inlined versions of the other core functions (tone, analogWrite, analogRead, etcetera) also designed to minimize the Flash consumed
  ? Dramatically improved Tiny Tuner
  ? Improvements the the Arduino ISP (aka Mega ISP) sketch
  ? Nice support for the ATtiny13
  ? Portability improvements

Quote
I mean, when the Arduino IDE 1.0 will be released, will the actual Tiny core be compatible with it or should we wait for a Tiny core 1.0?


No reason to wait.  The one change is enough that you can start using the 1.0 IDE.

leo72

Thanks for your replay.

nippet

#101
Oct 28, 2011, 02:46 am Last Edit: Oct 28, 2011, 02:56 am by nippet Reason: 1
Hi everyone.

I have a question in regards to programming capabilities of the ATtiny45/85.

Hopefully this question will be simple enough.

So like many others I have created a simple project for my Arduino Uno.
It works flawlessly and all is well, except I am exploring the idea of simplification.

Here is what it does:
User input - 10k POT on Analog 0
Output - PWM output Pin 9, duty cycle is controlled by the POT
All it does is drive a single solenoid position. (a control circuit handles the current)

Requirement: I have set a fixed 50Hz for the output using Timer.1, it must operate at this Hz.
PWM output then must be used through Timer.1, not Analogwrite.

Can this be reproduced using Attiny 45 or 85?
I have no experience using AVL(Assembler).
More importantly, using your Arduino Tiny release, can the 45 or 85 be programmed through the Arduino retaining the same functions?

Thanks for any help you can provide.

Coding Badly


By default, on the ATtiny85 family processors, timer 1 is used for the time functions (like millis).  Timer 0 is free for you to use.  You should be able to switch the roles so that timer 1 is available but that does not work correctly.

On ATtiny85 processors, timer 1 is a difficult beast because it is different than the ATmega timers.  Your application will probably not work on the ATtiny85 timer 1 without modification.

Timer 0 on the ATtiny85 processors is identical to timer 0 and timer 2 on the Uno processor.  If you can, I suggest getting your application to use timer 2.  If you can get that working, porting to the ATtiny85 is trivial (search-and-replace with some testing).

enjoyaol

Hi everyone,

I think I'm going to jump out of my place through the window ! I can't make the High low tech MIT tutorial to work properly. I have an attiny 85 20-PU, I guess it should be somewhat compatible with arduinoisp. Well, I connected my 3 leds to see what ArduinoIsp is doing, and the only thing I can get is that the heartbeat led is blinking properly. When I upload the blink sketch after having selected "Attiny 85 /w ArduinoISP", this 'heartbeat' led is just not heartbeating anymore, it's 'HIGH' only. And the other two leds are not blinking at all (the tree leds are correcly pinned, I see them blinking two time each when I reset the Arduino Uno).

Here is the error message I get:

Code: [Select]
Binary sketch size: 658 bytes (of a 8192 byte maximum)
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51


FYI, since I'm using an UNO, I connected a 100uF capacitor between Reset and Ground.

2nd part: I tried to use the Arduino Tiny latest files in place of the one found in the High-low tech page and It's doing the same thing. Please help :) Thanks !!!

Coding Badly

Hi,

Quote
I connected a 100uF capacitor between Reset and Ground.


At what point?

Go Up