Actions

ATtiny10

From Trammell Hudson's Projects

ATtiny10

ATTiny10 programming

The Tiny series of microcontrollers from Atmel are incredible, and the microscopic ATtiny10 is a neat addition to the product line. I've figured out how to program it with a FTDI cable using the DTR/CTS pins for additional signalling and wrote these instructions (that might be outdated now).

Using Darrel Tan's Programming the ATTiny10 instructions and a SOT-23 breakout board by Raphael, I was able to flash one of these very small MCU chips. Given the small package, these programmable devices can be dropped just about anywhere on a circuit that a transistor would be used. Unlike Tan, my FTDI breakout cable does not have DTR, so the reset pin on the chip needs to be pulled low manually to put it into programming mode, and the pinout adjusted.

TXD (Orange) --/\/\/--+
                      |   +----------------------+
CTS (Brown)  ---------+---| TPI DATA (1)   RESET | ------+
GND (Black)  -------------| GND              VCC | ---+  |
RTS (Green)  -------------| TPI CLK           NC |    |  |
                          +----------------------+    |  |
                                                      |  |
VCC (Red)    -----------------------------------------+  |
                        \                                |
GND (Black)  ---------   \-------------------------------+

In /usr/local/etc/avrdude.conf add:

programmer
  id    = "dasaftdi";
  desc  = "tiny10 no reset, sck=!rts mosi=!txd miso=!cts";
  type  = serbb;
  reset = ~4;
  sck   = ~7;
  mosi  = ~3;
  miso  = ~8;
;

Test program to generate a square wave output on pin D2. My version of avr-gcc doesn't support the ATTiny10, so I've hardcoded the register assignments and pass in the wrong device name to the compiler.

#define DDRB2 2
#define DDRB 0x01
#define PORTB 0x02

.global main
main:
        ldi r16, (1 << DDRB2)
        out DDRB, r16

loop:
        ldi r16, (0 << 2)
        out PORTB, r16
        nop
        ldi r16, (1 << 2)
        out PORTB, r16
        rjmp loop

Compile and generate an Intel hex file:

avr-gcc -mmcu=attiny11 test.S -o test.elf
avr-objcopy -O ihex test.elf test.hex

Manually pull the reset line to ground and flash with this command (substitute the correct path to your FTDI device:

avrdude \
  -p attiny10 \
  -c dasaftdi \
  -P /dev/tty.usbserial-FTE531WL \
  -U flash:w:test.hex 

If all goes well, release the reset line and put a scope on pin 4. You should see something like this:

Square wave from an ATTiny10

(Originally posted to the NYCR blog)