Arduino shrunk - how to use ATtiny13 with Arduino IDE

Arduino shrunk – how to use ATtiny13 with Arduino IDE

Lots of different MCUs can be worked on using the Arduino IDE, not just the Arduino boards!

Lots of different MCUs can be worked on using the Arduino IDE, not just the Arduino boards!

Arduino IDE (Integrated Development Environment), currently in version 1.0, is a great system for programming the Arduino boards. It has an easy-to-learn intuitive interface and comes with all the necessary settings for the most common Arduino boards – Uno, Duemilanove, Nano and others based on ATmega168 and ATmega328 microcontrollers. The latest version also includes some of the most recent ATmega1280 and ATmega2560 boards.
But you wouldn’t be using all of its great capabilities if you had to switch back to a text editor every time you needed to program a smaller Atmel chip, such as ATtiny13 for example. The engines behind the Arduino IDE – AVR-GCC compiler for C and C++ and avrdude – an in-system programming software for Atmel’s AVR series of micros – are already there and capable of coding for and programming the smaller chips, we just need to add a little bit of configuration magic to the Arduino IDE to be able to switch hardware freely without leaving your favorite Integrated Development Environment. Here is how:

{adinserter Internal_left}Arduino IDE keeps the hardware-specific C libraries and other necessary configuration files in a directory called hardware which can be either under the IDE’s root directory (from this point on I’ll call it [arduino_home] for brevity) or the user’s sketchbook directory. I am using a Ubuntu linux machine and my sketchbook directory is ~/sketchbook/. It can be a different location on a Windows PC – please check the manual for Win version.

The hardware-specific libraries are called cores and they are located under ~/sketchbook/hardware/xxxx/cores where xxxx can be either arduino or a hardware name that the developer of the libraries settled on – tiny, for example. It can also be under [arduino_home]/hardware/arduino/cores/

Another file crucial for IDE’s understanding of what hardware you’re working on is a file called boards.txt which is also located at ~/sketchbook/hardware/xxxx/boards.txt or /[arduino_home]/hardware/arduino/boards.txt The file contains information about the hardware (the “board” can be a stand-alone MCU, too ), such as the clock speed of the processor, high and low fuse bytes – the configuration settings that get “burned” into the microprocessor and define the clock source, timer prescaler and other important settings that don’t need to be updated every time you re-upload your sketch. boards.txt file can also prescribe how fast the programmer should talk to the MCU – an important issue for MCUs such as ATtiny that can be slowed down greatly by using an internal clock source.

So far I came across three different sets of libraries suitable for programming of ATtiny microcontrollers:

Most of them contain versions of several basic Arduino functions that can run on MCUs with such small Flash and SRAM sizes as the ATtiny. Most often supported functions include:


millis()
micros()
(not really a true microsecond)
delay()
delayMicroseconds()
(not really a true microsecond)
analogRead()
analogWrite()
pinMode()
digitalRead()
digitalWrite()

Keep this set of functions in mind when writing your software – more complex functions such as math and trigonometry functions may work but will probably exhaust resources of the little MCU too quickly.

All ATTiny cores install in a similar way:

  1. Shut down the Arduino IDE
  2. Identify the sketchbook directory (on Linux look for ~/sketchbook/) and create a new directory called hardware: ~/sketchbook/hardware.
  3. If the core is zipped with the directory structure, simply unzip the content of the zip file into the ~/sketchbook/hardware/ directory – it will create the subdirectory needed. Else, manually create a subdirectory called something like “tiny” (or “core13” as smeezekitty suggests for his core13 core. The name of the directory can be rather arbitrary, as long as it is the same as set up in boards.txt (below)
  4. Inside the ~/sketchbook/hardware/tiny/ directory, edit or create a new file called boards.txt (see the format below)
  5. The boards.txt file for ATTiny should contain this data (core13 core is used, replace with your core name if it’s different)

    ###########################################################################
    
    attiny13.name=Attiny13 @ 128 KHz (internal watchdog oscillator)
    attiny13.upload.using=arduino:arduinoisp
    attiny13.upload.maximum_size=1024
    attiny13.upload.speed=250
    attiny13.bootloader.low_fuses=0x68
    attiny13.bootloader.high_fuses=0xFF
    attiny13.build.mcu=attiny13
    attiny13.build.f_cpu=128000
    attiny13.build.core=core13
    
    
    ###############################################################
    
    attiny13at4.name=ATtiny13 @ 4.8MHz (internal 4.8 MHz clock)
    attiny13at4.upload.using=arduino:arduinoisp
    attiny13at4.bootloader.low_fuses=0x69
    attiny13at4.bootloader.high_fuses=0xff
    attiny13at4.upload.maximum_size=1024
    attiny13at4.upload.speed=9600
    attiny13at4.build.mcu=attiny13
    attiny13at4.build.f_cpu=600000
    attiny13at4.build.core=core13
    
    ###############################################################
    
    attiny13at9.name=ATtiny13 @ 9.6MHz (internal 9.6 MHz clock)
    attiny13at9.bootloader.low_fuses=0x7a
    attiny13at9.bootloader.high_fuses=0xff
    attiny13at9.upload.maximum_size=1024
    attiny13at9.build.mcu=attiny13
    attiny13at9.build.f_cpu=1200000
    attiny13at9.build.core=core13
    
    Arduino IDE 1.0 Pick the right Programmer before uploading the software

    Arduino IDE 1.0 Pick the right Programmer before uploading the software

  6. Once the configuration files are edited, start the IDE. In the Programmer section select the programmer you will be using (see picture on the left). I am using the Atmel AVRISP mk II USB programmer but Arduino itself can also be used for ICSP programming of AVR MCUs
  7. In the Tools->Board menu select the MCU and the clock speed you will be using (see picture at the top of the page).
  8. Before uploading any actual code, run “Burn Bootloader” – a menu item right next to “Programmer” under “Tools”. There is no Arduino bootleader for ATtiny because of the small memory and I/O size but the feature actually burns the low and high fuse bytes – the configuration step needed for making sure the MCU runs at the speed that you assume it does.
  9. Write some code while keeping in mind the hardware limitations – for ATtiny13 it’s 1024Byte FLASH and 64 byte SRAM and, obviously, only 5 x I/Os if you are planning to load the code via ICSP – the most convenient way to load the code. If you are going to use a different programming technique (which Arduino IDE won’t do, however), you can reuse the Reset pin as a 6th I/O.
  10. Connect ATtiny13 to the programmer as shown on this diagram

    Connect ATtiny13 to the programmer as shown on this diagram

  11. At this point in time, you should connect your ATtiny13 MCU to the programmer’s ICSP 6-pin header using the pinout in the picture on the left. If you’re building your project on a breadboard, it is always handy to have 6 x 18AWG colored wires soldered to a dual row 6-pin male header – it will make the programmer connection easy and can be reused from project to project. +1.9V to +5.5V power should be applied to Vcc before programming the chip.
  12. Upload the complied program into your ATtiny13 using the programmer

    Upload the complied program into your ATtiny13 using the programmer

  13. After you (think) you are done with the program, use the Upload Using Programmer [Ctrl-Shift-U] to compile the program and load it into the MCU. Remember that the power should be applied to the MCU before programming it!

Your program is now running! Or not … If it has bugs in it. If you’re not getting the intended operation of the MCU, verify the program and upload it again (steps 8-10).

One of the things to keep track of while writing a code for ATtiny13 is the amount of RAM your program is using. For example, each declared variable gets a space in RAM, and you should always use the shortest possible variable type. For example, if you have a counter that does not go over 255, there’s no need to use a 2-byte int type if 1-byte byte type will suffice. With only 64 bytes of RAM every byte counts!

If you’re declaring considerable size constants, such as arrays or text strings, consider using PROGMEM to move them from RAM to FLASH space, where you might have much more space to work with.

I’ve had great fun programming ATtiny13 chips with Arduino IDE. The IDE provides a very comfortable environment to work with and the limitations of the small MCUs like ATtiny13 make the programming even more interesting. If you haven’t yet, I think you should definitely add the ATtiny to your projects.

Happy coding!

66 Responses to “Arduino shrunk – how to use ATtiny13 with Arduino IDE”

  • smeezekitty:

    There is a small mistake that I posted about in the forum but other then that, Very Good!

  • smeezekitty:

    One more thing:
    attiny13at4.build.f_cpu=1200000

    in the boards.txt does not match the title of 4.8mhz

    •  Good catch again, smeezekitty! That is true, this was actually a remnant of my using 9.6MHz before: 9.6MHz divided by the default prescaler 8 gives 1200000. The actual value for 4.8Mhz with default prescaler is 600000.

      But is this the figure that the setting in millis() expects? I see

          #elif F_CPU == 4800000
          x = ovrf / 19;

      which would have been something for internal oscillator at 4.8MHz but it does not match the amount of overflows of a unsigned byte timer with default prescaler 8. I guess, in wiring.c we are using clock speed values after the prescaler has been applied?

      I’m getting

      4800000/1000/256 = 18.75 (just 19 then, since it really has no space for floating point) without prescaler and therefore with the default prescaler it would have been

      4800000/1000/8/256 = 2.34375 or simply 2.

      In other words, if we really-really wanted to run the chip at internal 4.8MHz oscillator with default prescaler 8 (and the slower it runs the less power it needs)  , we would need to add two lines into the wiring.c file, millis() function:

          #elif F_CPU == 600000

          x = ovrf / 2;

      Does that sound right?

      • smeezekitty:

        This is correct. Although I always turned the prescaler off and thats why I never added those but it will be added in version 0.14 which should be out very soon. Remember that delayMicroseconds will also need some modification (which is more difficult). I still need to adjust the timings in delayMicroseconds when I have more time to work on it. I will not even bother supporting the 128khz clock / 8 (16khz) or 32.768khz crystals since the timings would be unreasonably wrong.

  • Eraticus:

    I have installed smeezekitty’s core13 in various places in my ~/Documents/Arduino/hardware directory, including:
    a) ~/Documents/Arduino/hardware/core13
    b) ~/Documents/Arduino/hardware/tiny/core13
    c) ~/Documents/Arduino/hardware/tiny/cores/core13

    However, no matter what I do, I always get this error in the Arudino IDE: /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:212:26: error: pins_arduino.h: No such file or directory

    It seems that after successfully reading the board definition in ~/Documents/Arduino/hardware/tiny/boards.txt, it cannot find the source files, and is error-ing while looking in the application’s root directory instead. Though I am not against putting core13 in my Arduino app root, I’d very much like to put it in my sketch directory, as you have in your tutorial. Sorry to bother you with this, but if you have any insight as to what I’m doing wrong, I’d greatly appreciate it!

    Sincerely,

    Eraticus

    •  Which version of the Arduino IDE is this? This sounds like an error an older 0022 version would produce. If you haven’t switched yet, I would definitely advise to go for the newer 1.0 version because it is much more convenient to use with MCUs without the Arduino bootloader.

    • smeezekitty:

      I put it in: arduino-0022/hardware/arduino/cores/core13/
      I am not really sure about putting it in other directories.

  • Eraticus:

    In your boards.txt sample file, the last build.core= entry is inconsistent with the others. This might cause problems for those using your board.txt template to get the core13 lib working.

    •  Thank you for pointing that out. Yes, there are a couple of ways to skin this particular cat, so to speak. That last boards.txt entry is for a different core, the Damellis’es ATtiny cores . I really wanted to show that there are a couple of ways of doing this in Arduino IDE but you are right, it may get confusing. The entry for core13 would look like

      attiny13.name=ATtiny13 @ 9.6MHz (internal 9.6 MHz clock)
      attiny13.bootloader.low_fuses=0x7a
      attiny13.bootloader.high_fuses=0xff
      attiny13.upload.maximum_size=1024
      attiny13.build.mcu=attiny13
      attiny13.build.f_cpu=1200000
      attiny13.build.core=core13
      
      • Edwin:

        Hmmm
        I am even more confused now about the boortextfile

        Attiny@128 KHz -> attiny13.build.f_cpu=128000 yes that makes sense
        Attiny@4,8 MHz -> attiny13at4,build.f_cpu=600000 hmmmm???
        Attiny@9.6 MHz -> attiny13.build.f_cpu=9600000 yes makes sense

        with regard to Smeezekitty’s remark you then say it is because of the prescaler, but that actually you have to add 2 lines in the wiring.c file

        With regard to Eraticus’ remark you then correct the @9.6MHz entry to be 1200000, which seems in line with teh 9.6 entry but out of line again with the 128kHz entry.
        Am I correct to think that the 128000kHz then does not use the prescaler?

        You say that the 9.6MHz entry originally was for the Damelli’s core, that then I presume does not use a prescaler.
        I furthermore presume that you switch off the prescaler by the fuse settings??

        • smeezekitty:

          The /8 prescaler is settable on any clock.
          The title in the boards.txt is incorrect since the prescaler is set.
          Either the prescale fuse should be unset or it should be titled 600KHZ.

          128000 / 8 = 16KHz which is simply too slow for practical use.

          • Edwin:

            Now I am even more confused
            Which title is not correct the @128, the @4,8 or the @9.6?
            Do I understand now that the @4.8Mhz actually is @600kHz
            Which of these 3 entries now has a prescaler set and which has not?

          • Edwin:

            If I look at the fuses then I would see the following

            7B=128 kHz (no prescaler)
            69=4.8 MHz (with prescaler set) so actuually it is 600 000kHz
            7A=9.6MHz (no prescaler set) but the frequency is stil set as 1200000

            Let me summarise, is there a correct Boardstextfile somewhere for your current core (13-016) as it is not included in the core file

          • Edwin:

            oops 600 000Hz ofcourse, not kHz

  • […] order to keep this post to a manageable size, I would like to refer you to an earlier post – How to use ATTiny13 with Arduino IDE which describes setting up Arduino IDE to compile code for and burn it into the smaller AVR chips, […]

  • ed:

    I feel a bit stupid on saying this, regarding your remark about code that might not work and I am sure we all do it, but unless you really know for sure what you are doing (you won’t) run it in a regular IDE/Arduino environment first (just realize you may have to redifine the pin numbers coz Arduino uses 1 and 2 for serial transmission).

    If it all works then set the proper pin numbers and program the chip.

    Now only if the IDE had conditional pin definitions:
    If 328 {motorpin=4} Else {motorpin=0};
    that would be great

    • smeezekitty:

      I believe that is possible.
      #if defined(__AVR_ATmega328__)
      #define MOTORPIN 4
      #else
      #define MOTORPIN 0
      #endif

  • tobi:

    Is there a way to use the pulseIn function?

  • CaviaR:

    Hi all! If I compile the simple Blink example code, it will be 1070byte, so its over the 1k memory. Its the simplest code, it does not contains any library or bigger methods but even it can fit in. How can I compile a code to fit on this little memory, or wheres the trick? 🙂 Thank you!

    • smeezekitty:

      My guess is you are compiling the sketch for a standard Arduino (Duemilanove or Uno) and not for an Attiny13.
      After modifying your boards.txt file, select Attiny13 as the board type.

      The blink sketch compiles to about 360 bytes with Core13 on my machine.

  • hey i’m trying to use your libarary to do an analog read. i’ve connected it to A3 pin on the tiny13 and have a simple LDR with pull up resistor running 5v through it.

    all i’m expecting is when a change in voltage on the Analog input pin changes the state of the LED, but its not triggering, works fine on the arduino. am i doing something wrong?

    int ldr = A3;
    int ldrvalue = 0;
    int ledPin2 = A0; //will use PWM function of this pin later

    void setup() {
    pinMode(ledPin2, OUTPUT);
    pinMode(ldr, INPUT);
    }

    void loop() {
    int t = analogRead(ldr) / 100; // cheaper than smoothing
    digitalWrite(ledPin2, LOW);
    if ( ldrvalue != t ) {
    ldrvalue = t;
    digitalWrite(ledPin2, HIGH);
    delay(2000);
    digitalWrite(ledPin2, LOW);
    delay(2000);
    }
    }

    • smeezekitty:

      Ensure you are using the newest library version.
      Earlier versions sporadically hung when reading the ADC.

      • Jean:

        I actually have the same problem, a small code reading the ADC on physical pin 2 and 3 (thus ADC 3 and 2)
        It works on an Attiny85 but not an attiny13. Upgraded to the newest version… makes no difference.

        Still a problem with ADC hanging perhaps?

        • Jean:

          I got it solved already. Apparently there needs to be a analogReference(0); statement in the setup. then it works

    • Richard:

      The fuse bits are set differently in core13 for the three speeds. 4.8Mhz sets the /8 giving a result of 600000. But the 9.6Mhz setting do not enable the /8, resulting in the standard 9600000 setting.

      I put my files into arduino/hardware/attiny13/cores. Should i leave the core13 reference or change it to attiny13?

      rep

  • I cannot seem to get either of these working with Arduino 1.0 software and interfacing with Uno board:
    –Damellis’es ATtiny cores
    –smeezekitty’s core13
    I am running Debian Linux (Sid), Arduino v1.0.1.

    With smeezekitty I get:
    > fatal error: Arduino.h: No such file or directory
    I’ve tried to put his folder structure into Debian’s folder at
    /usr/share/arduino/hardware/arduino/cores/core13/
    and I’ve triad variations on putting it into
    /home/lefty/arduino/sketchbook/hardware/core13/
    but still no go with any of these. Somewhere I read to copy the Arduino 1.0 software’s official Arduino.h into the core13/ directory (overwriting the provided one) but that didn’t work; same error.

    I feel like I am a little closer with Damellis’es setup, my error being:
    > avrdude: usbdev_open(): did not find any USB device “usb”
    which I don’t know if that comes before or after the request for the ‘missing’ Arduino.h file from the other setup. I’ve read that these Damellis’es settings should work with ATtiny2313 which is another chip I have to play with. But with these Damellis’es files, you’ve not provided a useful boards.txt config at all so I don’t know what to do for that 🙁

    Can you help at all? And, can you edit the article so that you have proper configs for each of these Attiny13 cores ? The combined config is confusing, and it is also incomplete for each core.

    Thanks for the work so far and I look forward to getting this functioning!

    • here are a few cores for your arduino..

      download this file: https://docs.google.com/open?id=0B0N5FlIrsEEwZnN5ZlZ5NjVSWG8

      extract into the ~/Arduino folder (where the sketchbook path is from preferences), it needs to be called “hardware” and restart arduino, mines setup to use the Atmel stk500hvsp so you’ll need to modify the boards.txt file to set it back to the one that works for you. this includes tiny45/85 tiny13 tiny1312 i’ve used it successfully with the tiny85 and tiny13’s

      update as required.

    • L.C., when you say “interfacing with Uno board”, do you mean you are using it as a programmer? These tiny cores are for stand-alone MCUs (without bootloaders), so there’s really no “interfacing” here – you need a programmer to burn the binaries compiled using these cores into the MCUs. Perhaps I just misunderstood your situation but this phrase as well as the error message you are quoting later have nothing to do with ATTiny cores – seems like the Arduino IDE hasn’t been properly setup yet.

      ATtiny cores aside, can you interface with that UNO using just fresh stock Arduino IDE setup? I mean, download Arduino IDE again, unzip into a different directory and run if from there. Select UNO as the target board and try to uplpoad some blinker sketch or something easy like that.

      • @admin sorry for the confusion. I can use the Arduino IDE fine with my Uno; I’ve used the examples and I’ve written a few basic programs/sketches for my Uno.

        I meant to say, when I set the Uno into ArduinoISP mode (which seems to work fine) and then use the Uno to program an ATtiny13 (which I called ‘interfacing’), that is where I get the errors. The errors I’ve reported are by trying to load the Blink example code, change that code to Pin 3, and upload it to the ATtiny13.

        I’ll dig more into this soon, hopefully tonight. Any info provided would be a great help! Thanks all.

        • smeezekitty:

          Very likely the directory structure is incorrect in the first case.

          “avrdude: usbdev_open(): did not find any USB device “usb””
          Sounds like a problem in boards.txt

          • I have the Blink example uploaded to my ATtiny13 but the LED just remains on; it doesn’t blink. I’ve tried adjusting pins etc but it’s the same for them all.

            This guy
            https://tekstop.wordpress.com/2011/12/30/programming-attiny13-using-arduino-isp-and-all-the-hacking-involved/
            seems to track down the problem in the Arduino software but I wasn’t finding the specified lines in the file ‘iotn13.h’

            SO CLOSE, can anyone tell me if his bug is a real issue still or if something else is causing me troubles?

            > “avrdude: usbdev_open(): did not find any USB device “usb””
            > Sounds like a problem in boards.txt
            That doesn’t seem to be the case so far as i can tell; it turned out that I needed to add udev rules (hardware driver configuration on Linux)
            http://academy.cba.mit.edu/content/tutorials/09_Embedded_Programming/Programming_ATtiny_with_Arduino_IDE.html

          • If you used either smeezekitty’s or Damellis’es cores, you don’t need adjusting pin assignments in the core – they are already properly mapped. You just need to make sure you refer to the proper numbered B port I/Os (which Arduino calls D – D0 through D5) Anyhow, post your sketch here so we can see and let us know how the LED is hooked up – which pin on the ATtiny13 (and then, I assume, through a resistor up to the positive power rail, right?)

            Note that you really need to avoid using D5 (pin #1) if you want to (easily) reprogram the ATTiny through ISP – it’s also the reset pin.

            Below is the pinout and Arduino D numbers:

            //       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
            //                 +----+
             
             */

            Make sure you’re addressing the proper hardware pin in your sketch.
            Cheers!

          • I’ve just remembered another thing: make sure you use the “Burn Bootloader” function before uploading your sketch – I know if sounds counter-intuitive because ATtiny13 does not have a bootloeader but selecting this function in Arduino IDE also burns the configuration fuse bits into the ATtiny13, and one of them defines the clock speed. If you are running at a slower clock frequency than you think you do, you may end up with a ve-e-e-e-e-e-ry slow blink which will look to you as “always ON”. An exact opposite is also possible – with too fast a speed the LED may actually be blinking but your eye is not able to catch it if it blinks faster than 30Hz.

  • > If you used either smeezekitty’s or Damellis’es cores, you don’t need adjusting pin
    > assignments in the core – they are already properly mapped. You just need to make sure
    > you refer to the proper numbered B port I/Os (which Arduino calls D – D0 through D5)

    I don’t know exactly what that means, but I’ve not changed anything in the cores files and I’ve wired the ATtiny13 like this:
    ATtiny Pin1 – Uno Pin10
    ATtiny Pin4 – Ground
    ATtiny Pin5 – Uno Pin11
    ATtiny Pin6 – Uno Pin12
    ATtiny Pin7 – Uno Pin13
    ATtiny Pin8 – 5v DC (VCC) Pin

    > Anyhow, post your sketch here so we can see and let us know how the LED is hooked up –
    > which pin on the ATtiny13 (and then, I assume, through a resistor up to the positive
    > power rail, right?)
    I am just opening the Examples > Blink option and changing the LED from Pin 13 to Pin 4; I then have an LED on D4 (ATtiny13 pin 3) through a resistor to the rail. I’ve learned about the ‘Burn Bootloader’ and that’s helped remove errors in the compiling, but the LED is still solidly lit. I don’t think it’s going slow nor fast, I think it isn’t timing correctly as that one post mentioned, in the iotn13.h file
    https://tekstop.wordpress.com/2011/12/30/programming-attiny13-using-arduino-isp-and-all-the-hacking-involved/

    > Note that you really need to avoid using D5 (pin #1) if you want to (easily) reprogram
    > the ATTiny through ISP – it’s also the reset pin.
    Avoid it, at which point? For general use? or for programming? I’m not avoiding it during programming, as I noted above. I’ve tried removing all connections after the sketch is uploaded, other than power, ground, and the LED, but no fix.

    > I’ve just remembered another thing: make sure you use the “Burn Bootloader”
    > function before uploading your sketch – I know if sounds counter-intuitive
    > because ATtiny13 does not have a bootloeader
    I’ve learned to do this, but it isn’t counter-intuitive to me — this is all new and none of it is intuitive! 🙂 The D ports, the B I/O, none of it makes much sense right now. I’m working on it.

    Thanks so much for the help so far… I’d be happy to move this all to the forum if you’d prefer.

    Still so close, so so close…

  • […] hanging to the left of the box. Otherwise, load the Arduino sketch (below) in the Arduino IDE (here is how to setup Arduino IDE to program Attiny13) and upload it using a programmer of your choice, such as the Arduino […]

  • […] If you need help loading Arduino sketches into ATtiny13 MCUs, see this post on using Attiny13 with Arduino IDE here. […]

  • Darren:

    How do you know which functions are supported for this chip? Is there a reference someplace?

    • Darren, sorry for the delay with response. That is a great question! I don’t know if a reference document exists (doubtful). When I’m not sure if a function is supported, I simply run a full text search for a function name in the directory containing the core files. If it’s not listed in any of the files, the sketch won’t compile. You can also just look at the compilation errors of course.

  • […] ArduinoISP on the Leonardo 2) Arduino Leonardo pin out 3) Arduino shrunk – how to use ATtiny13 with Arduino IDE 4) Programming an […]

  • Arun:

    Hi,

    I believe low_fuses = 7A is 9.6 MHz without prescaler. For 9.6/8 = 1.2 MHz the low_fuses should be 6A.

    I used: http://www.engbedded.com/fusecalc

    Right?

    Thanks.

  • I believe you are correct. I think that’s how we have it in the boards.txt file here. Am I missing something, are you pointing out an error in the codes on this page? Please clarify.

  • Arun:

    Sorry, I suppose I should have been clearer.

    In the boards.txt above the configuration for attiny13at9 – is f_cpu=1200000 (1.2 MHz). So, the low_fuses should be 0x6a instead of 0x7a, shouldn’t it?

  • lokthelok:

    Is this likely to work with an ATTiny13A? I had a bit of a try with no luck.
    My application is a LED Driver board for a high power CREE LED

  • smeezekitty:

    It should work with any Attiny13 series

  • nihaopaul:

    Confirmed. It does work with both attiny13a and attiny13, same code no modifications needed. I had a project last month were I used both.

    P

  • lokthelok:

    Thanks. Hopefully I can get mine working!

  • Dokta:

    I placed the ‘boards.txt’ and the unzipped core (smeezekitty’s) into …SketchBook/Hardware/core13/ but all I get when I open the IDE/Tools/Board/ is four blank lines at the top of the list. They are selectable but the text is missing.

    Any assistance would be greatly appreciated, thank you.

    “Je suis Charlie!”

    Dokta

  • lokthelok:

    Hey, Dokta.
    I recall having similar issues when I was playing with this. Though it was a long time ago…
    Have you checked the contents of boards.txt? Try checking that the names in there match with what’s in core 13. I’m just spitballing here as I haven’t had a chance to play with arduino for a while.
    I assume you would have had a look at: http://playground.arduino.cc/Main/CustomizeArduinoIDE

    I’ll have a play in a week or so when I’ll get the chance. Best of luck.

    • Dokta:

      Thank you for your response and forgive the late reply. Unfortunately I have been away on ‘family matters’ and will research your suggestion as soon as I can. I did find a way around the problem but when I got back to ‘normality’ (family problems solved)an update to the Arduino IDE deleted all reference and I don’t have time at the moment to retrace my steps. When I do solve this I will post the solution here.

  • Edwin (different one):

    Very good article.
    I kindalost over the time what cores I am using so now I am in the situation in which I have one computer that works with attiny45/85 (I think that is the HIGH-LOW-MIT one), but not with attiny13, and another computer that works with attiny13 and not with 45/85 🙂 The latter is SmeezeKitty I think
    For now I leave it as such, but go to sort it out one day.
    Anyway, with regard to the commands that are supported: the list at the bottom of the article is correct, but I think that has become some sort of standard that is mentioned everywhere.The core for my attiny13 (again, I think smeezekitty) for instance knows ‘MAP’, but that takes about half of the program space 🙂 so for simple map operations better to divide by 4. I also have used PulseIn on the attiny85

    • smeezekitty:

      Well, yes. Floating point math means it has to link in the FPE which is very large.
      I suggest avoiding it wherever possible. I feel the map() function is for newbies
      but it is both faster and smaller to use math specific to what you are trying to do

      • ed:

        Agreed,pulseIn and shiftOut work as well on the Attiny13, but seem to take 52 resp 45% of program memory. Not much left then :-).
        As I also have some Attiny10’s, this might be a good time to dive into Atmel assembler a bit

  • Alchemix:

    ATtiny 13/44/84/45/85 cores for Arduino 1.6.x

    Looking for support for attiny85 and attiny13 I found this: https://github.com/Marzogh/ATtiny

    It states:
    The ATtiny13 core in this version of ATtiny cores for Arduino is built on the work done by John “smeezekitty” and based on his Core13 release. The ATtiny44/84/45/85 cores in this version of ATtiny cores for Arduino are built on the work done by David Mellis “damellis” from the High-Low Tech Group MIT Media Lab and based on his attiny release.

Leave a Reply

Or use the Forums ! If your comment is a question, please consider posting it to a matching section of our Electronics Forums. The forums allow for a more natural conversation flow, especially if multiple replies are required. Additionally, you'll be able to style your writing (bold font, italics etc.) and post images which can help with a good answer.