Arduino Tiny

Yes and yes.

Hi all,

I have a AtT4313 and want to use its inboard UART. When ever it try to upload the sketch it fails with this error:

Binary sketch size: 2350 bytes (of a 4096 byte maximum)
avrdude: ERROR: address 0x0810 out of range at line 129 of C:\Users\xxx\AppData\Local\Temp\build7553309411575013505.tmp\RX_Blink_ATT2313.cpp.hex
avrdude: write to file 'C:\Users\xxx\AppData\Local\Temp\build7553309411575013505.tmp\RX_Blink_ATT2313.cpp.hex' failed

Im trying to get a Serial LCD to display data. Here is the code:

const int CR = 13;

void setup(){
  Serial.begin(9600);
  for (int i=0; i<15; i++){
    Serial.print(CR, BYTE);
  }
}

void loop(){
}

void LCDWrite(int s) {
  Serial.print("ad");
  Serial.print(s);
  Serial.print(CR, BYTE);
}

I know the Attiny2313 only has 2048 of flash but the Attiny4313 has 4096 of flash.

I have increased the size in boards.txt.

attiny2313at1.upload.maximum_size=4096

and i have updated the core to support the Attiny4313.

Can anybody help?

Thanks

Question about SoftwareSerial support. Is there any change to have the new SoftwareSerial lib that is shipped with Arduino 1.0 works with the last Tiny core 1.0? I tried today an example but I get some errors during compilation. Or should I continue to use the old NewSoftSerial modded to work with Tiny cores?

@dlar: The Tiny Core has support for the ATtiny4313. Just use the latest version.

leo72:
Is there any change to have the new SoftwareSerial lib that is shipped with Arduino 1.0 works with the last Tiny core 1.0?

I don't know. I believe the Arduino 1.0 SoftwareSerial is very very similar to the previous NewSoftSerial. If they are similar then SoftwareSerial, like NewSoftSerial has to be modified to work on ATtiny processors.

I tried today an example but I get some errors during compilation. Or should I continue to use the old NewSoftSerial modded to work with Tiny cores?

There does not appear to be any new bug fixes and just one new feature...
http://arduiniana.org/libraries/newsoftserial/
http://code.google.com/p/arduino/issues/list?q=softwareserial

So, it looks like the best course is to continue using the modified "old" NewSoftserial.

The libraries are different. SoftwareSerial has been changed and if you download NewSoftSerial1.2 you can check that libraries don't match.
SoftwareSerial has taken the "write" method instead of "print" one, following the new trend of the Arduino IDE 1.0 but those methods conflict the some code in the tiny/cores/tiny/Print.h file.
I will try to use the "old" & modded NewSoftSerial1.2 instead of the SoftwareSerial.

One question. Why did you remove the links to the old Tiny core from Google code?
Isn't it possible to download the old 0022 version?
Forget about it.... I had just to click on "deprecated downloads" :sweat_smile:

using linux mint I followed the instructions on arduinos page to install 1.0 on ubuntu, everything works fine until I hit the tiny, using the latest and greatest core I get the following

In file included from /usr/share/arduino/hardware/arduino/cores/tiny/WProgram.h:17,
                 from /usr/share/arduino/hardware/arduino/cores/tiny/Arduino.h:4,
                 from Blink.cpp:8:
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:629: error: ‘TINY_DEBUG_SERIAL_REGISTER’ was not declared in this scope
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:629: error: ‘TINY_DEBUG_SERIAL_BIT’ was not declared in this scope
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:629: error: template argument 1 is invalid
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:629: error: template argument 2 is invalid
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:629: error: invalid type in declaration before ‘;’ token
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:630: error: ‘TINY_DEBUG_SERIAL_REGISTER’ was not declared in this scope
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:630: error: ‘TINY_DEBUG_SERIAL_BIT’ was not declared in this scope
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:630: error: template argument 1 is invalid
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:630: error: template argument 2 is invalid
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:630: error: invalid type in declaration before ‘;’ token
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:631: error: ‘TINY_DEBUG_SERIAL_REGISTER’ was not declared in this scope
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:631: error: ‘TINY_DEBUG_SERIAL_BIT’ was not declared in this scope
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:631: error: template argument 1 is invalid
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:631: error: template argument 2 is invalid
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:631: error: invalid type in declaration before ‘;’ token
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h: In member function ‘void TinyDebugSerial::begin(long int)’:
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:682: error: cannot convert ‘TinyDebugSerialWriter_9600*’ to ‘TinyDebugSerialWriter*’ in assignment
/usr/share/arduino/hardware/arduino/cores/tiny/TinyDebugSerial.h:686: error: cannot convert ‘TinyDebugSerialWriter_38400*’ to ‘TinyDebugSerialWriter*’ in assignment

while uploading a simple blink sketch ... help?

Which board do you have selected?

attiny 84 @ 8 mhz

I can't find any problems.

using the latest and greatest core

Did you get it from the Source tab, Downloads tab, or the Home tab? Maybe one of the links is pointing to something out-of-date.

downloads tab

I think I figured it out, using the instructions here

http://arduino.cc/playground/Linux/Debian

under

Arduino 1.0 and Arduino UNO on Debian squeeze (6.0.3)

arduino would not work correctly, so looking back though what I did I installed arduino and arduino core from the normal repositories, which gives you version 18, then ran the above which gives you 1.0 functioning, but apparently it does not upgrade everything. I tried the version of tiny for arduino 19 and guess what, it works

least for me

so yea I have 1.0 as the IDE and apparently .18 for most of the core files ... !@*#$! linux

Hello, Coding Badly!
Huge thanks for your tiny core!

I've been playing around with a small sketch for Tiny85 (a multifunction 1-Wire slave). I'm not using real Tiny85 yet, but Proteus simulation.
I'm using Arduino v0.22.
At some point I started to get R_AVR_13_PCREL error on each compile.
Then I upgraded WinAVR according to your instructions in your post:

The error has gone and I accomplished everything I wanted.

Today I tried to write some code for Uno board. The code compiles without errors, but when uploading I get error:
avrdude: stk500_getsync(): not in sync: resp=0x00
I can only get rid of it after renaming the old backup "avr_old" folder back to "avr".
Does it mean, that I'll always need to use obsolete toolchain when working with Uno? Or I'm just doing someting wrong?

And 2 more questions:

  • Is it possible to run Tiny85 at 16Mhz using internal oscillator and PLL as clock source?
  • delay() seems not to work on Tiny85 at 8Mhz (int. osc.). (might be Proteus simulation bug, but it works ok with HLT core).

Hello Kyrill,

Huge thanks for your tiny core!

You are welcome.

Does it mean, that I'll always need to use obsolete toolchain when working with Uno?

I have not had to. I've been using the latest version of WinAVR since long before I created that post. I use my Uno nearly everyday and have had no upload problems.

Or I'm just doing someting wrong?

Could be. Collect verbose output from an upload attempt and post it to the forum.

  • Is it possible to run Tiny85 at 16Mhz using internal oscillator and PLL as clock source?

Yes. I think the latest version has a boards entry for it ... yup ... Google Code Archive - Long-term storage for Google Code Project Hosting.

  • delay() seems not to work on Tiny85 at 8Mhz (int. osc.). (might be Proteus simulation bug, but it works ok with HLT core).

By default, the Tiny Core uses timer 1 for millis on the ATtiny85 processor whereas the HLT core uses timer 0. Timer 1 on the ATtiny85 is unique in the AVR world. I suspect Proteus does not simulate the timer correctly.

Collect verbose output from an upload attempt and post it to the forum.

I get only one red line:
avrdude: stk500_getsync(): not in sync: resp=0x00
The behaviour of board LEDs is also different. When using old toolchain, after compilation finishes the board resets, then Rx/Tx LEDs flash several times (1/2 seconds for small 2K code), then the board starts to execute code.
With new version, after compilation the board only resets and starts old code execution. The arduino environment still waits about 20 sec with status "uploading", then displays the above described single red line.
By the way, I tried to upload to a Mega1280 board, erevything works ok with both old and new version.

I think the latest version has a boards entry for it

That's cool, didn't notice version 0012 is out. Will definitely try it ASAP.

Timer 1 on the ATtiny85 is unique in the AVR world. I suspect Proteus does not simulate the timer correctly.

OK. Thanks for clarification.

I'm using the arduino tiny software (Google Code Archive - Long-term storage for Google Code Project Hosting.) to try and control two servos with an ATtiny84. I have quite some timing problems as it seems to be. When I connect one servo to pin PA6 and use this software:

// Based on Sweep
// by BARRAGAN <http://barraganstudio.com> 
// This example code is in the public domain.
// Changed by Johan

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
int pos = 0;    // variable to store the servo position 
int posMin = 17;
int posMax = 65;
 
void setup() 
{ 
  myservo.attach(4);  // attaches the servo on pin 4 to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = posMin; pos < posMax; pos += 1)  // goes from posMin degrees to posMax degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  delay(3000);
  for(pos = posMax; pos>=posMin; pos-=1)     // goes from posMax degrees to posMin degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
    delay(3000);
}

This works well...

However, I need to control two servos. Their position should be the same so I tried to connect them to one output. This makes the servos to jiggle with no avail. I also can't seem to get the servos work on another port.
I have tried using internal clock at 8Mhz and 16Mhz with an external resonator. Also capacitors.

Any ideas?!

Update:

// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// This example code is in the public domain.


#include <Servo.h> 
 
Servo myservo1;  // create servo object to control a servo 
Servo myservo2;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
int pos = 0;    // variable to store the servo position 
int posMin = 17;
int posMax = 65;
 
void setup() 
{ 
  myservo1.attach(4);  // attaches the servo on pin 9 to the servo object 
  myservo2.attach(5);  // attaches the servo on pin 9 to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = posMin; pos < posMax; pos += 1)  // goes from 0 degrees to 180 degrees 
  {             // in steps of 1 degree 
    myservo1.write(pos);
    delay(7);
    myservo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(7);                       // waits 15ms for the servo to reach the position 
  } 
  delay(3000);
  for(pos = posMax; pos>=posMin; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                     
    myservo1.write(pos);
    delay(7);
    myservo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(7);                      // waits 15ms for the servo to reach the position 
  } 
    delay(3000);
}

this also works when connecting one servo to 4 or 5 but not when I connect two servos to either port.

@jopiek:
One servo on one pin works?

One servo on one pin and a second servo on a second pin works?

Two servos on on pin does not work?

Kyrill:

Collect verbose output from an upload attempt and post it to the forum.

I get only one red line:
avrdude: stk500_getsync(): not in sync: resp=0x00

If you don't get a long sign-on message from avrdude it is not in verbose mode.

I'm using Arduino v0.22.

Hold down the Shift key when you click upload.

@Coding Badly:

Almost:
A with one servo works (B no servo)
B with one servo works (A no servo)

Problems when:
1 connecting two servos to either A or B
2 connecting servos to A and B

Do I need to do anything special to get the 85 working at 128KHz? I had to comment out serial commands and I still get this error:

In file included from C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny\wiring.c:30:
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/core_adc.h:55:4: error: #error Add an entry for the selected processor speed.
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny\wiring.c: In function 'init':
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny\wiring.c:257: error: 'ADC_ARDUINO_PRESCALER' undeclared (first use in this function)
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny\wiring.c:257: error: (Each undeclared identifier is reported only once
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny\wiring.c:257: error: for each function it appears in.)

This is my code, nothing fancy just sequencing the PWM:

int list[7] = {
  -1,-1,-1,-1,-1,-1,-1};
byte const set[7] = {
  B001,B010,B011,B100,B101,B110,B000};
boolean redo = true;
int x = 0;
int count = 0;
int count7 = 0;

int LED1 = 0;
int LED2 = 1;
int LED3 = 4;

int curVal[3] = {
  0,0,0};
int lastVal[3] = {
  0,0,0};
int nextVal[3] = {
  0,0,0};

void setup(){
  //Serial.begin(9600);
  //Serial.println("Reset");
  randomSeed(analogRead(0));

  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  writeList();
      for (int i = 0;i<3;i++){
      nextVal[i] = (bitRead(set[list[0]],i)==1)? 255:0;
    }
    //Serial.print(list[0]);
}


void loop(){
  for(int i=0;i<3;i++){
    curVal[i] = map(count,0,255,lastVal[i],nextVal[i]);
  }

  analogWrite(LED1,curVal[0]);
  analogWrite(LED2,curVal[1]);
  analogWrite(LED3,curVal[2]);


  if(count==255){
    count = 0; 
    if (++count7==7){
      count7 = 0;
      //Serial.println(" ");
      writeList(); 
    }

    for (int i = 0;i<3;i++){
      lastVal[i] = nextVal[i];
      nextVal[i] = (bitRead(set[list[count7]],i)==1)? 255:0;
    }
    //delay(map(analogRead(1),0,1023,1,50) * 200);
    delay(200);
   // Serial.print(list[count7]);
  }
  count++;
  //delay(map(analogRead(1),0,1023,1,50));
  delay(1);
}


void writeList(){
  int l = list[6];
  for(int i = 0;i<7;i++){
    list[i] = -1;
  }
  for(int i = 0;i<7;i++){
    redo = true;
    while(redo){
      x=random(7);
      if(list[x]==-1){
        redo=false;
        list[x] = i;
      }
    }
  }
  if(list[0]==l){
    int y = random(1,7);
    x= list[y];
    list[y] = list[0];
    list[0] = x;
  }
}

It works fine on any of the other attiny85 settings

thanks