Evan Rust
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 hour9,675
Programming an ATtiny13A in Assembly

Things used in this project

Hardware components

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

Software apps and online services

Microchip Studio
Microchip Studio
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

Evan Rust

Evan Rust

120 projects • 1054 followers
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.

Comments