Главнокомандующий
Сообщений всего: 248
Дата рег-ции: Февр. 2011
|
.nolist
.include "m8def.inc" ; Header for ATMEGA8
.list
.def rmp = R20 ; Multipurpose register
.def pos = r19 ; posizia
.def flag = r16; flag impulsa
.dseg
.org 0X0060
.cseg
.org $0000
rjmp Main ; Reset vector
rjmp EXT_INT0; Int vector 1
reti ; Int vector 2
reti ; Int vector 3
reti ; Int vector 4
reti ; Int vector 5
reti ; Int vector 6
reti ; Int vector 7
reti ; Int vector 8
reti ; Int vector 9
reti ; Int vector 10
reti ; Int vector 11
reti ; Int vector 12
reti ; Int vector 13
reti ; Int vector 14
reti ; Int vector 15
reti ; Int vector 16
reti ; Int vector 17
reti ; Int vector 18
EXT_INT0:
cli
ldi flag,0b00000001
sei
reti
Main:
; Init stack
ldi rmp, HIGH(RAMEND) ; Init MSB stack
out SPH,rmp
ldi rmp, LOW(RAMEND) ; Init LSB stack
out SPL,rmp
; Init Port c
ldi rmp,0b00001111 ; Direction Port c
out DDRc,rmp
ldi rmp,0b11110000
out portc,rmp
ldi rmp,0b0
out ddrd,rmp
ldi pos,0b11110001
ldi flag,0b00000000
ldi rmp, 1<<ISC01 ;po spadu 1-0
out MCUCR,rmp
ldi rmp, 1<<INT0 ;razreschim int0
out GIMSK,rmp
sei
Loop:
cpi flag, 1
brne loop
out portc,pos
ldi R17, $3F
WGLOOP0: ldi R18, $F
WGLOOP1: dec R18
brne WGLOOP1
dec R17
brne WGLOOP0
ldi rmp,0b11110000
out portc,rmp
sbrs pos,0
rjmp m1
ldi pos,0b11110010
rjmp ex_loop
m1:
sbrs pos,1
rjmp m2
ldi pos,0b11110100
rjmp ex_loop
m2:
sbrs pos,2
rjmp m3
ldi pos,0b11111000
rjmp ex_loop
m3:
ldi pos,0b11110001
ex_loop:
ldi flag,0b0
rjmp loop ; go back to loop |