A Streamlined IDE for Coding and Programming the ATtiny10 and other ATTiny Devices
A Streamlined IDE for Coding and Programming the ATtiny10 and other ATTiny Devices
Update: As of July 29, 2020, In order to support the 64 bit-only Catalina release of macOs, I have revised the code to use thinned versions of Microchip's 64 bit GNU Toolchains rather than using 32 bit GNU toolchains extracted from the Arduino project.
Update: As of Dec 16, 2020 - I have revised the toolchain loader code to fix some GNU compile errors.
ATTiny10IDE is a simple, GNU-based IDE I originally wrote to simplify writing code for the ATTiny10 Series Microcontrollers using C. C++ or Assembly language. This new version is a greatly expanded and updated version I started working on in 2014. See this article for some additional details on how this project started. For this new release, I've added support for the ATTiny25/45/85 and ATTiny24/44/84 series of microcontrollers, as well support for programming them using an ICSP Programmer. And, there's also an experimental feature for automatic generation of function prototypes.
If you just want to try out the program, you don't need to download and compile the source code, as I maintain a pre-built, executable JAR file in the out/artifacts/ATTiny10IDE_jar folder from which you can download and run ATTiny10IDE as long as you have Java installed on your system. On a Mac, simply double click the ATTiny10IDE.jar file to run it once you've downloaded it, although you'll probably have to right click and select "Open" the first time you run ATTiny10IDE due to the Mac OS X security check and the fact that I'm currently unable to digitally sign the JAR file. You should also be able to double click and run using Windows, but some versions of Windows may require you to enable this ability first. You'll need to give the .jar file RUN permission to execute on Linux and using a USB-based device programmer, such as the AVRISP MkII, may also require you to create an install a rules file.
So far this is just a one man project and I struggle at times to do adequate testing, especially on Windows and Linux, when I release a nw version. So, if anyone spots a problem, or has a question or a sugegstion, please post an issue so I can investigate. You can also email me at questions4wayne at gmail dot com.
I suggest using Java 8 JRE or JDK, or later for ATTiny10IDE, but the code also seems to run under the OpenJDK Java on Linux. Note: I wrote ATTiny10IDE on a Mac Pro using the Community version of IntelliJ IDEA from JetBrains and OS X is the only environment where I have extensively tested and used ATTiny10IDE . I've included GNU/AVR toolchains for Mac and 64 bit Windows and 64 bit Linux, but have not extensively tested the code under Windows or Linux. Feel free to report any issues you discover. I'll do my best, when time permits, to investigate them, but I cannot guarantee fixes, timely or otherwise.
ATTiny10IDE supports coding for the ATTiny10 Series of Microcontrollers in C and C++ using the GNU AVR-C++ compiler to generate code. In addition, ATTiny10IDE supports two ways to write and assemble code the ATTiny10. One method uses the GNU AVR-AS assembler using a non Atmel-type syntax. The other uses a homebrew assembler I wrote that supports an Atmel-like syntax. The file extension you choose for your code file tells ATTiny10IDE how to process the code:
.c - Compile as C file using avr-gcc
.cpp - Compile as C++ file using avr-g++
.s - Assemble using avr-as and link with avr-ld
.asm - Assemble with my homebrew assembler (Note: only supports the ATTiny10)So, this means you'll have to save your source file with the appropriate extension before you can compile, or assemble it. In addition, you can also write inline assembly code in a C/C++ (.c) file. You'll find examples of these different approaches to writing code in the examples folder.
ATTiny10IDE supports several different ways to program your compiled code into an ATTiny10 chip. One is to build and use the Arduino-based, High Voltage programmer/emulator I designed for the original version of my IDE. However, ATTiny10IDE also now supports a way to generate an Arduino Sketch (program) which, when run, can directly program an ATTiny10 chip using only Arduino I/O lines 2 - 6, like this:
Here are the steps you can follow to program an ATTiny10 using this method:
File->Open" to load the source file, or type your code into the "Source Code" pane and save it using the appropriate file extension.Actions->Build" to compile. or assemble the code.Actions->Generate Arduino Programmer Code" and save to a .ino (Arduino Sketch) file when prompted.I' and pressing "Send".P' and pressing "Send"You can use this Sketch to program as many ATTiny10s as needed, but you can also use it as a general-purpose ATTiny10 programmer to upload and program other code, like this:
Settings->Programmer" to open the Programmer dialog and select the "Arduino TPI" option.Actions->Build" to compile. or assemble the code.Actions->Read Device Signature" to verify the ATTiny10 is properly connected.Actions->Program Flash and Fuse(s)" to upload and program the code into the ATtiny10.I've also created a small, inexpensive PCB that implements the wiring shown in the above photo. You can order it from OSH Park, for $1.10 for three copies of the PCB. Note: I don't receive anything from OSH Park for offering this. I do it just to make it a bit easier for you to program ATTiny10 chips using ATTiny10IDE. In the following photo, the ATTiny10 is soldered to an SOT-23-6 to DIP 6 adapter PCB. This kind of SMD to DIP adapter is widely available from many sources, or you can order 3 copies of a SOT-23-6 to DIP 6 adapter I designed from OSH Park. To complete the first adapter PCB you'll need two, 3 pin, .1 inch spacing female headers, which serve as a socket for the SOT-23-6 to DIP adapter PCB, and a 5 pin strip of .1 inch spacing male headers, which you can snap off from a 40 pin, .1 inch breakaway header strip. You also need two, 3 pin strips of the male header for the SOT-23-6 adapter PCB, too.
To use the programming adpater, simply plug it in to data pins 2 through 6 on the Arduino and then plug the SOT-23-6 to DIP adapter into the female headers on the programming adapter PCB being careful to align pin 1 to pin one on both boards. Once programmed, the SOT-23-6 to DIP adapter makes it easy to plug it into a breadboarded circuit to test your code.
Arduino.h to code "sketches" in ATTiny10IDEWhen coding in C or C++, ATTiny10IDE expects you to put your code in a function named main() and handle all the details of using the low-level ATTiny10 architecture which involves ading and writing to hardware registers to perform I/O operations. However, if your file starts by including the header file Arduino.h, like this:
#include "Ardiuno.h"you'll be able to write code in a way that is familiar to users of the Arduino IDE. Instead of writing a main() function, your one-time initialization code will go in a function named setup() and code that executes again and again will go into a function named loop(). Arduino calls a program like this a "sketch". The example program Blank.h is a sample starting sketch you can copy to start coding. It looks like this:
#include "Arduino.h"
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}In addition, Arduino.h provides a set of convenience functions you can call to do digital and analog I/O in a fashion similar to how the Arduino IDE handles these operations. These include pinMode(), digitalWrite(), digitalRead(), analogWrite(), analogRead(), delay() and delayMicroseconds(). The digital I/O functions are implemented as #define macros, which the GNU compiler is able to efficient convert to quite optimal code. But, be aware that you'll get the most compact and efficient code when the values passed for pin numbers resolve to constants at compile time. For example, a call to digitalWrite(2, HIGH) compiles to the single instruction, sbi 0x02,2, in ATTiny10 assembly language.
Calls to analogRead() and analogWrite() go to actual C functions because some initialization steps are required the first time one of these functions is called. For this reason, trying to use the same pin for both analog and digital I/o is not recommended, as the initialization code will not run a second time. If you need to do this kind of function switching with pins, you'll need to develve into how to write code that directly manipulates the low-level I/O registers in the ATTiny10. Note: check out some of the more advanced example programs, such as TimerBlink.c and PulsingLED.c, to see how you can use C/C++ code to directly access the ATTiny10's I/O registers.
Calls to delay() and delayMicroseconds() are also handled by #define macros but redire
No open issues yet, or sync has not completed.