Arduino “having11” Guy
Published © GPL3+

Programming an ATtiny13A in Assembly

Use an ISP programmer and Atmel Studio to flash a blink program to an ATtiny13A, which has just 64 bytes of memory!

BeginnerFull instructions provided1 hour2,491
Programming an ATtiny13A in Assembly

Things used in this project

Hardware components

AVRISP MkII Programmer
×1
Microchip Technology ATtiny13A
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Atmel Studio 7
Microchip Technology Atmel Studio 7
Chili Peppr
Autodesk Eagle

Hand tools and fabrication machines

CNC Router
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schemtaic

Board Schematic

Code

ATtny13A Assembly

Assembly x86
It's actually AVR Assembly, ignore the x86
.include "tn13adef.inc"
.org 0                         

init:
    ldi r16, (1<<PB3)			; load bit for PB3 into r16    
    out DDRB, r16               ; PB3 as output

loop:
    sbi PORTB, PB3              ; set bit 2 of PORTB
    rcall timer                 ; go to timer label
    cbi PORTB, PB3              ; clear bit 2 of PORTB
    rcall timer					; go to timer label
    rjmp loop					; loop back to beginning

timer:
    ldi r16,0                   ; these are timer counters
    ldi r17,0
    ldi r18,5

timer2:
    inc r16                     ; do 256 iterations - 1 clock
    brne timer2					; branch if not equal to beginning of timer2 - 1 clock * 256, then 1
    inc r17                     ; do 256 times - 1 clock
    brne timer2					; branch if not equal to beginning of timer2 - 1 clock * 256, then 1
    dec r18						; do 5 times - 1 clock
    brne timer2                 ; branch if not equal to beginning of timer2 - 1 clock * 5, then 1
    ret                         ; once there have been 256 * 256 * 5 loops, return

Credits

Arduino “having11” Guy

Arduino “having11” Guy

81 projects • 538 followers
18 year-old IoT and embedded systems enthusiast. Also an intern at Hackster.io who loves working on projects and sharing knowledge.

Comments