Pages: [1] 2 3 ... 16   Go Down
Author Topic: core13: An Arduino core for the Attiny13 *testers wanted*  (Read 40578 times)
0 Members and 2 Guests are viewing this topic.
Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am writing a Arduino core for the Attiny13.
It will support a subset of the Arduino functions and is of relatively small size.
So far it seems to work but I have not tested it completely.
I have not tested it thoroughly and I only tested it with 128khz internal oscillator.
Supports 128KHz, 600KHz, 1MHz, 1.2MHz, 4MHz, 4.8MHz, 8MHz, 9.6MHz, 10MHz, 12MHz and 16MHz clock speeds (Although not all are tested)
If anyone gets a chance give it a try.
Although programming a microcontroller with this little flash space with a Arduino core is alittle impractical, it helps the beginners greatly.
For the most part, I read the Arduino core source code and rewrote most of it from scratch.
It may work for other 8 pin Attiny series but I cannot promise.
Currently supported functions:
* = Partial support
Code:
map()
random()
randomSeed()
millis()
micros() *
delay()
delayMicroseconds()
analogRead()
analogWrite()
pinMode()
digitalRead()
digitalWrite()
edit: fixed bugs and attached new version.
edit: Added support for 4, 4.8Mhz and improved support for 9.6Mhz
edit: Released 0.15 that fixes bugs

Fixed bug and compiler error. Added more F_CPU support. Some other fixes.
From now on download from sourceforge.net for the newest release https://sourceforge.net/projects/ard-core13/

* core13_0_135.zip (9.91 KB - downloaded 208 times.)
« Last Edit: August 16, 2012, 08:41:20 pm by smeezekitty » Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No interest? I am surprised.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 206
Posts: 12849
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Dude.  Patience.  A large number of users only visit the forum weekly or less often.  In addition, from an Arduino perspective, the core is for an esoteric processor.

For what it's worth, I plan to look it over this weekend.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 132
Posts: 6744
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Needs instructions for how to add it to the IDE...
Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Dude.  Patience.  A large number of users only visit the forum weekly or less often.
Ok. I am not often a patient person.
Quote
In addition, from an Arduino perspective, the core is for an esoteric processor.
Limited but hardly esoteric.
[/quote]
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Needs instructions for how to add it to the IDE...

On windows it will usually go in
Code:
C:\arduino\arduino-<version>\hardware\arduino\cores\core13
in my case it would be
Code:
C:\arduino\arduino-0022\hardware\arduino\cores\core13
I added this to my boards.txt:
Code:
attiny13.name=Attiny 13A standalone

attiny13.upload.using=arduino:arduinoisp
attiny13.upload.maximum_size=1024
attiny13.upload.speed=19200

attiny13.bootloader.low_fuses=0x7B
attiny13.bootloader.high_fuses=0xFF
attiny13.bootloader.path=empty
attiny13.bootloader.file=empty

attiny13.bootloader.unlock_bits=0xFF
attiny13.bootloader.lock_bits=0xFF

attiny13.build.mcu=attiny13a
attiny13.build.f_cpu=128000
attiny13.build.core=core13
But be sure to change the fuses, f_cpu and programmer to match what you will be using.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded your file. Moved it into the Arduino directory. Selected ATTINY 13A Standalone as the board and Arduino as ISP for the programmer.

When I try and verify or upload the code, it says 'pinMode' was not declared in this scope.

I am sure it is something as simple as not including a file thats required but I thought I would ask here first before I start messing with stuff.

Also, thanks for taking the time to work on the Tiny13...
Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded your file. Moved it into the Arduino directory. Selected ATTINY 13A Standalone as the board and Arduino as ISP for the programmer.

When I try and verify or upload the code, it says 'pinMode' was not declared in this scope.

I am sure it is something as simple as not including a file thats required but I thought I would ask here first before I start messing with stuff.

I failed to make the instructions clear enough.
You have to extract the zip file to
Code:
C:\arduino\arduino-<version>\hardware\arduino\cores\core13
Note: The folder core13 will not exist.
Note2: I have not tested this with IDE version 1.0 although it should work.
Quote
Quote
Also, thanks for taking the time to work on the Tiny13...
Most people are put off by only 1k of flash...
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Pennsylvania, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Trying to make sense of it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice work and thank you for taking on this project! I've been looking for Tiny13 core for a very small project and was agonizing over the decision to embark on writing my own  smiley-red - too small a project ... And finally I've found yours!

Anyhow, I've tried it with 0022 and 1.0 on Linux

I'm still looking into the code but the result so far as follows:

0022 complies the code fine though avrdude is not finding the MCU (I'm using AVRISP MKII programmer) - it looks for t13 but sees attiny13a and throws an error.

1.0 does not compile - it's not finding the core at either of the two possible locations:

~/sketchbook/hardware/arduino/codes/core13
or
~/arduino_directory/hardware/arduino/cores/core13

trying to burn a bootloader with the programmer on V1.0 does not go either - same error as on 0022 (wrong MCU name)

I'm still looking around but maybe you can see what I'm doing wrong here?

Cheers!
Logged


 /\_/\      ARDUINO
((@v@))     CNC
()~|~()

Pennsylvania, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Trying to make sense of it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

All right, thanks again, smeezekitty!

I am blinking some LEDs here using Arduino 1.0 (linux) with ATtiny13  smiley-grin

The problem was indeed the file locations. As far as I can tell, it depends on which  boards.txt file you are adding your ATtiny13 entry to. I already had the ATtiny libraries by Damellis installed (ATtiny13 is missing there) and therefore I was using the boards.txt located at
Code:
~/sketchbook/hardware/tiny/boards.txt
So, I just added an entry to the other ATTiny cores' boards.txt:

 
Code:
###########################################################################

attiny13.name=Attiny13 @ 128 KHz (internal watchdog oscillator)

attiny13.upload.using=arduino:arduinoisp
# attiny13.upload.protocol=avrispv2
# attiny2313at1.upload.using=pololu

attiny13.upload.maximum_size=1024
attiny13.upload.speed=19200

attiny13.bootloader.low_fuses=0x7B
attiny13.bootloader.high_fuses=0xFF
attiny13.bootloader.path=empty
attiny13.bootloader.file=empty

attiny13.bootloader.unlock_bits=0xFF
attiny13.bootloader.lock_bits=0xFF

attiny13.build.mcu=attiny13
attiny13.build.f_cpu=128000
attiny13.build.core=core13

###########################################################################

In this case the smeezekitty's core had to be located at
Code:
~/sketchbook/hardware/tiny/cores/core13/

Additionally, since this is Arduino 1.0, a small Arduino.h file needs to be added. I just copied one from the other core package:
Code:
#ifndef Arduino_h
#define Arduino_h

#include <WProgram.h>

#endif

The timer seems a bit off (actually, runs twice as fast as far as I can tell) but that's a 128kHz oscillator, I haven't looked at the prescaler and also, it may just be very inaccurate. I'll look into it later.

That was pretty much it!

Anyhow, great job, smeezekitty!
Logged


 /\_/\      ARDUINO
((@v@))     CNC
()~|~()

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The timer seems a bit off (actually, runs twice as fast as far as I can tell) but that's a 128kHz oscillator, I haven't looked at the prescaler and also, it may just be very inaccurate. I'll look into it later.

That was pretty much it!

Anyhow, great job, smeezekitty!

This could be a bug.
The 128khz oscillator is inaccurate but not that inaccurate. Its about +- 30%.
It seems to run about the correct speed here although I have not tested it on Linux or Arduino 1.0.
Please post the code you used to make it blink.
I will investigate this further.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Pennsylvania, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Trying to make sense of it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've also looked at it and it turns out that I had to use the "Burn Bootloader" feature in IDE 1.0 which for a Tiny simply means that the fuses are burned correctly. Until then the timer was not setup correctly. Also I've switched to the internal 9.6MHz calibrated oscillator is the timing is perfect now. Here are the fuses:

Code:
attiny13.bootloader.low_fuses=0x7a
attiny13.bootloader.high_fuses=0xff

Please note that I'm sort of integrating your core with Demellis'es . I honestly could not find a way to burn the fuses with yours - the bootloader file was missing or I simply failed to find it. How'd you do it? 

Cheers!
Logged


 /\_/\      ARDUINO
((@v@))     CNC
()~|~()

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've also looked at it and it turns out that I had to use the "Burn Bootloader" feature in IDE 1.0 which for a Tiny simply means that the fuses are burned correctly. Until then the timer was not setup correctly. Also I've switched to the internal 9.6MHz calibrated oscillator is the timing is perfect now. Here are the fuses:

Code:
attiny13.bootloader.low_fuses=0x7a
attiny13.bootloader.high_fuses=0xff
Be sure to adjust F_CPU as well.
Quote
Please note that I'm sort of integrating your core with Demellis'es . I honestly could not find a way to burn the fuses with yours - the bootloader file was missing or I simply failed to find it. How'd you do it? 

Cheers!
I did not include a bootloader file because the attiny13 is too small for a bootloader.
I burned the fuses with avr-dude on the command line prior to using the Arduino IDE.
BTW I uploaded a new version that fixes a few minor bugs relating to clock speed.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Offline Offline
Full Member
***
Karma: 0
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry but the attiny 13 nave only 1 k of flash , and only the sketch blink is 1.2k , what worldwide you do whit the attiny 13 ?, thanks for the core
Logged

Non possiamo pretendere che le cose cambino, se continuiamo a fare le stesse cose(albert Einstein )

Pennsylvania, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Trying to make sense of it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry but the attiny 13 nave only 1 k of flash , and only the sketch blink is 1.2k , what worldwide you do whit the attiny 13 ?, thanks for the core
1.2K is a lot of bytes for a blink! The code must be not well optimized or sometin'  . You can do plenty of useful things with 1K of command space. For example, here is a code for a 10-LED light chaser (can convert it into Cylon eyes  or some other such blinking toy) and it compiles into only 562 bytes. In fact, there might even be some saving there still, I just didn't have too much time to optimize it.
Code:
/*
  Charlieplexing example for ATtiny13
  This code is for a 10-LED bargraph display. You can increase the amount of LEDs controller by the Tiny to 20 if needed.
  Code by Elabz.com
http://elabz.com/
  This example code is in the public domain. If you end up using it in a project, please drop me a message, I'd be happy to
  know it was of some use. I'll also be happy to feature your project on my site, so send some pictures, too: http://elabz.com/site/contact/
 
//       ATMEL ATTINY13 / ARDUINO
//
//                 +-\/-+
// ADC0 (D 5) PB5 1|    |8 Vcc
// ADC3 (D 3) PB3 2|    |7 PB2 (D 2) ADC1
// ADC2 (D 4) PB4 3|    |6 PB1 (D 1) PWM1
//            GND 4|    |5 PB0 (D 0) PWM0
//                 +----+

 
 
 */
int j; // just a counter
boolean d; // direction forward=true
//int bitmap[]={1,2,1,4,1,8,2,4,2,4};
byte bitmap[]={B00000001,B00000010,B00000001,B00000100,B00000001,B00001000,B00000010,B00000100,B00000010,B00001000};
byte outModes[]={B00000011,B00000011,B00000101,B00000101,B00001001,B00001001,B00000110,B00000110,B00001010,B00001010};



void setup() {
d=true;
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
/*  for(int i=0;i<5;i++) {
    pinMode(i, OUTPUT);   
} */
 
}

void loop() {
 
 byte outModeNow =  outModes[j] ;
  byte bitmapNow=bitmap[j];
  if(j>8)
  { d=false;
  }else if(j<1)
  { d=true;}
  if(d){j++;}else{j--;}
  DDRB = outModeNow;
 // PORTB = B00000000;
  PORTB = bitmapNow;
  delay(50);              // wait

}

Hope this helps,

Cheers!
Logged


 /\_/\      ARDUINO
((@v@))     CNC
()~|~()

Pages: [1] 2 3 ... 16   Go Up
Jump to: