ATtiny2313 Template File


Untuk memudahkan dalam membuat program-program untuk AVR ATtiny2313, berikut adalah contoh file template assembler versi saya yang perlu banyak dikritiki dan disarani.

File template atau skeleton ini saya buat untuk program assembler GAVRASM.
;------------------------------------------------
; ATtiny2313-Skeleton
; File skeleton/template untuk AVR ATtiny2313
; Dibuat oleh Chandra MDE
; Tanggal 5 Januari 2009

;------------------------------------------------

;------------------------------------------------
; DEVICE = ATtiny2313
;------------------------------------------------
.device ATtiny2313

;------------------------------------------------
; Definisi tambahan

;------------------------------------------------
.def TEMP = r16         ; contoh

;------------------------------------------------
; Data-data di SRAM

;------------------------------------------------
.DSEG
data1: .byte 1          ; contoh
data2: .byte 1          ; contoh
data3: .byte 1          ; contoh

;------------------------------------------------
; Data di EEPROM

;------------------------------------------------
.ESEG
edata1: .db 1           ; contoh
edata2: .db 2           ; contoh

;------------------------------------------------
; Program Memory

;------------------------------------------------
.CSEG
.ORG 0x0000

;------------------------------------------------
; Interrupt Vector ATtiny2313

;------------------------------------------------
reset:
rjmp start
; rjmp interrupt0               ; External Interrupt0
; rjmp interrupt1               ; External Interrupt1
; rjmp tim1_capture             ; Timer1 Capture
; rjmp tim1_cmp_matchA          ; Timer1 Compare Match A
; rjmp tim1_overflow            ; Timer1 Overflow
; rjmp tim0_overflow            ; Timer0 Overflow
; rjmp usart0_rxc               ; USART0 RX Complete
; rjmp usart0_dre               ; USART0 UDR Empty
; rjmp usart0_txc               ; USART0 TX Complete
; rjmp analog_comparator        ; Analog Comparator
; rjmp pcint                    ; Pin Change Interrupt
; rjmp tim1_cmp_matchB          ; Timer1 Compare Match B
; rjmp tim0_cmp_matchA          ; Timer0 Compare Match A
; rjmp tim0_cmp_matchB          ; Timer0 Compare Match B
; rjmp usi_start                ; USI Start
; rjmp usi_overflow             ; USI Overflow
; rjmp eeprom_ready             ; EEPROM Ready
; rjmp wdt_overflow             ; Watchdog Overflow

;------------------------------------------------
; Konstanta>/code>
;------------------------------------------------
author:
.db "Chandra MDE",0
.db "https://telinks.wordpress.com", 0, 0

;------------------------------------------------
; Awal program setelah direset

;------------------------------------------------
start:
;-----------------------
; Setting STACK POINTER

;-----------------------
ldi TEMP, RAMEND
out spl, TEMP

;-----------------------------------------
; Inisialisasi I/O Port, Timer, Dll.

;-----------------------------------------
ldi TEMP, 0xff
out DDRB, TEMP  ; PB0-PB7 = output

;------------------------------------------------
; Looping program utama

;------------------------------------------------
forever:

;-----------------------------------------
; Contoh: Output PORTB on-off tanpa delay

;-----------------------------------------
out PORTB, TEMP
com TEMP

rjmp forever

;------------------------------------------------
; End Of File

;------------------------------------------------

Selamat belajar!

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s