Caution: this project is still in the Alpha stage and I make no guarantees about how easily you'll be able to reproduce my work, or actually do anything useful with it. I present it here as a work in progress that may, or may not be useful to you.
Update1: The assembler now support simple expressions, such as 1 << 2, label + 2, etc., as well as comma separated lists of values in .dw and .dw expressions
Update2: I've found cases where the programmer can no longer program a device after PB3/RESET (pin 6) is configured as an output pin. It seems to work fine to use PB3 as an input, however. So, until I get this resolved, I recommend that you don't use PB3 as an output.
Update3: New version of ATinyIDE.app.zip (replaces ATinyIDE.app) to fix a reported problem with app not running on OSX Lion.
Update4: Fixed errors in programmer schematic to show correct connections to Arduino (A1-A5.)
Update5: New versions of ATinyIDE.app.zip and ATTiny10ProgrammerHV_PCB.pde (download below) include an automatic way to calibrate the ATTiny10's internal clock. Details on how this works added in new "Automatic Clock Calibration" section.
Update6: If you are unable to select a serial port please try the suggestion in the "32/64 Bit Issues" section near the bottom of this page.
This project creates a complete IDE for coding in assembly language for the ATTiny10 and then programming it. The complete system consists of the following components:
Well, the ATTiny10 and it's siblings, the ATTiny 4,5 & 9, are the smallest and cheapest members of the AVR 8 Bit family. The chips are enclosed in an SOT-23-6 package, which means they are really, really tiny. And, purchased in units of 10, the little brother of the set, the ATTiny4, is only $.73. That means they're so cheap you can almost sprinkle them around in your projects. Need an LED that blinks in Morse code, use an ATTiny4 to drive it. The ATTIny10, at $1.10 in units of 10, is still pretty cheap and you get twice as much program space as the ATTiny4 (1024 vs 512) and a 4 channel ADC, to boot.
The programming circuit is adapted from my ATTiny Fuse Reset with 12 Volt Charge Pump project (note: Arduino connections are different, however, so the software from that project will not work with this board) but adds a 6 pin socket for plugging in an ATTiny10 device mounted on a SOT-23 to 6 pin DIP adapter board. The schematic for this adapter is shown next:
The parts list for this circuit (excluding the pin strips needed to plug the board into the Arduino) is, as follows:
The PCB layout for this circuit as shown next:
The circuit is simple enough to construct on an Arduino prototyping shield, but it's simpler to use the PCB I designed and which you can order directly from Sparkfun's BatchPCB service, using this link: ATTiny10Programmer. The cost is $8, but it will take a few weeks to get, as the BatchPCB service is a "produce on demand" service where the board are fabbed in China and then sent as a batch to Sparkfun which, in turn, mails your portion of the order to you.
When assembled and attached to an Arduino, the finished PCB will look like this (notice the 6 pin DIP to SOT-23 adapter containing the ATTiny10 chip plugged into the 6 pin socket):
Note: the tiny black speck underneath the letters "ETT" is the ATTiny10
Arduino Code: the complete Arduino source code for the programmer is available here, or from the attachment section below.
ATTiny10 IDE and Assembler
The IDE I created to work with the programmer is a Java application packaged as an Mac OSX app which, when run, creates a window like this:
My idea was to create a simple way to type in ATTiny10 assembly code into the "Source Code" window, then using options in the "Actions" menu to build the code and then program it directly into a device plugged into the programming circuit. However, before you can do this, you need to first do the following steps:
Next, to program an ATTiny device, follow these steps (note: these instructions assume you have a working version of the Arduino 022 IDE already installed and working):
Automatic Clock Calibration
The IDE now contains a "Calibrate Clock" option in the "Actions" menu. To use this feature, you must have an Arduino with the programming shield attached connected (see above) and an ATTiny10 in the programming socket. Then, simply select "Calibrate Clock" and wait while the IDE download a small clock calibration program onto the ATTiny10 and runs a calibration sequence to determine the correct clock offset value. When done, the calibration process will have printed text like this into the "Programmer" tab's text area:
The Recommended Clock Offset value is the value you can then use to adjust this particular ATTiny10's clock to as close to 8 MHz as the clock tweaking process will permit. However, before this will wrk, you will need to add code to your ATTiny program's startup sequence to set this value using code like this:
Note: the calibration process will overwrite whatever code you have installed on the ATTiny10. Also, the accuracy of the calibration process is dependent upon the accuracy of the Arduino's 16 MHz oscillator, so you may get better results using the clock calibration process I describe here. Also, be aware that the calibration process needs to be repeated for each individual ATTiny10 IC, as the value needed to tweak the clock will vary from chip to chip.
The assembler I wrote for the IDE is fairly crude, brute force affair and has a lot of limitations, but it's getting better with time.
In Circuit Programming?
Most of my work has been directed toward getting to know the capabilities of the ATTiny10 series, so working with the chips mounted on adapter boards (which I then plug into various breadboard for testing) has worked fine for me. In theory, my design could be used as in circuit programmer as long as the needed pins can be made available. However, this is tricky, as 12 volts will be applied to the RESET line (pin 6) during programming, so your circuit would need to be protected from this. And, the prorgammer will need to be able to freely toggle pins 1 and 3, as well as raise and lower the Vcc line. So, this imposes a heck of a lot of limitations on the circuit you would need to design for your board. I'd be curious to hear your experiences if you try it, but I don't recommend using my design in this fashion.
As always, start by double checking everything, especially the orientation of the 4 diodes. If even one is put in wrong, the circuit won't generate 12 volts and the programmer code won't be able to read the device signature, or program the device. It's probably a bit late to mention this but, as I mentioned before, traces can be shorted on new PCBs, so it's wise to use the continuity tester function on a volt meter to check for short, or opens before assembling the PCB. If you didn't of this, it's not too late, as most of the circuit is connected by capacitors, so you can still check for many shorts after the fact. If all this fails, try reloading the code into the Arduino.
If you run into trouble with the assembler, make sure your not trying to do something my feeble minded assembler just can't do, such as parse expressions, or deal with anything other than basic assembler instructions, or the limited set of directives I coded into it. Carefully check the Listing pane to see if there are any errors reported (note, my assembler is a deficient in error reporting category, too, so you may have to look carefully for things like skipped instructions, etc.)
Why Did I Create This?
One thing I obsess over is tiny things. I'm a bit of a minimalist at heart, so when I first saw the new ATTiny 10 series, I wanted to work with them. Build things with them. But I quickly became frustrated, as all of Atmel's tools seemed to fall short. For one thing, Atmel previously had a part called the ATTiny10 that, as far as I can tell, was never produced. This caused me no end of confusion when I was trying to find software to work with these new ATTiny devices. In addition, the ATTiny10 series changed the format of certain instructions (specifically, the LDS and STS instructions, which are only 2 bytes long on the ATTiny10, vs 4 bytes on other ATTiny devices) to fit better with the limited Flash memory and this makes the code incompatible with most other ATTiny chips. So, I decided to create my own tools to I could at least have a chance to fix them if they failed to do what I wanted them to do.
I'd like to put out a Windows and Linux version at some point, but it's just not high up on my list of priorities right now. Actually,if you're clever with Java, you might be able to extract and run the IDE on Windows, or Linux, if you extract the .class files from the ATTinyIDE.app file (in OSX, simply select "Show Package Contents" then open the path Contents->Resources->Java to get at the .class files.) One hitch is that IDE uses the RXTX serial libraries to talk to the Arduino and my code may not work with the Windows or Linux versions of RXTX. I profess to not having a lot of knowledge about how to integrate my code with RXTX on those platforms. It was actually hard enough to get this all packaged up for OSX.
Eventually, I'd like to replace my lame assembler with something cooler, such as a real AVR assembler, or even a C compiler, if GCC ever happens to support the ATTiny 4,5,9 and 10 series chips (perhaps is does now on other platforms, but it doesn't seem to on the Mac.) Note: as of 12/2/2012, I have a C compiler working with a modified version of this IDE. Stay tuned for more details.
32/64 Bit Issues
With recent changes to the Java environment, you may need to run this IDE in 32 bit mode if you are using a recent version of OSX, such as Mountain Lion. To do this, select the ATTinyIDE.app and then select "Get Info" from the "File" menu. Then click the checkbox marked "Open in 32-bit mode" then close the dialog box.
If you have any suggestions, or questions about this project, contact me at "wayne dot holder at gmail dot com".