- Код: Выделить всё • Развернуть
.include "C:\Program Files\Atmel\AVR Tools\AvrAssembler2\Appnotes\m48def.inc"
.def tmp=R16
.cseg
.org 0x0000
rjmp Init
.org PCI1addr
rjmp RcvInit
Init:
ldi tmp,(1<<PCINT8)
sts PCMSK1,tmp
ldi tmp,(1<<PCIE1) ;External interrupt presetting
sts PCICR,tmp
clr tmp
out DDRC,tmp
ser tmp
out DDRD,tmp ;PortD for input data dispatching
ldi tmp,0b00101100 ;MOSI,SS,SCK-out, MISO-in
out DDRB,tmp
ldi tmp,(1<<SPE)|(1<<MSTR)|(1<<SPR0)|(1<<CPOL)
out SPCR,tmp
sei
Start:
nop
nop
rjmp Start
RcvInit:
ldi tmp,3 ;READ instruction
out SPDR,tmp
SendAddr:
in tmp,SPSR
sbrs tmp,SPIF
rjmp SendAddr ;Waiting for previous transfer complete
in tmp,SPDR
ldi tmp,0x01 ;Read from 0x01
out SPDR,tmp
RcvData:
in tmp,SPSR
sbrs tmp,SPIF ;Waiting for previous transfer complete
rjmp RcvData
in tmp,SPDR
out PORTD,tmp ;Out PortD
reti
Почему может не работать?
На всякий случай приложу проект целиком.