; vcc card --- atmel vcc
; vcc cam ---
; rst cam --- atmel int0 (pd2)
-; rst card --- atmel (pb4)
+; rst card --- atmel (pd4)
; clk card -\
; - atmel t1 (pd5)
; clk cam -/
ldi r16,low(RAMEND)
out SPL,r16
-;
-; hier weiter ....
-;
-
; enable interrupts int0,int1
ldi r16,((1<<INT0)|(1<<INT1))
out GIMSK,r16
; int0/1 setup
ldi r16,((1<<ISC01)|(1<<ISC00)|(1<<ISC10)|(1<<ISC11))
out MCUCR,r16
-in r16,MCUCR
-sbic PORTD,PD2
-cbr r16,ISC00
-out MCUCR,r16
-sbic PORTD,PD3
-cbr r16,ISC10
-out MCUCR,r16
-; enable t/c overflow interrupt
-ldi r16,(1<<TOIE1)
+; enable t/c overflow interrupt and icp
+ldi r16,((1<<TOIE1)|(1<<TICIE1))
out TIMSK,r16
-; setup t/c
-ldi r16,((1<<CS12)|(1<<CS11)|(1<<CS10))
+; setup t/c and icp
+ldi r16,((1<<CS12)|(1<<CS11)|(1<<CS10)|(1<<ICNC1))
out TCCR1B,r16
; init bitcounter and overflow counter
ldi r20,0 ; bitcounter
ldi r21,0 ; register for constructing the byte
ldi r22,0 ; overflow counter
+ldi r23,0 ; temp reg
; constant 1 in r1
ldi r16,1
; enable interrupts (global)
sei
+; jump to mainloop
+rjmp MAIN
+
+;
+; main routine
+;
+
+MAIN:
+
+rjmp MAIN
+
;
; rec_card routines
;
REC_CARD:
-; int0 -> input, int1 -> output
-ldi r16,(1<<DDD3)
-out DDRD,r16
-
; decide what to do
-sbic PORTD,PD2
+sbic PORTD,PD6
rjmp REC_CARD_HIGH
rjmp REC_CARD_LOW
REC_CARD_HIGH:
; output high on port to cam
-ldi r16,(1<<PD3)
-out PORTD,r16
+sbi PORTD,PD3
-; toggle int0 sense
-in r16,MCUCR
-cbr r16,ISC00
-out MCUCR,r16
+; toggle icp sense
+cbi TCCR1B,ICES1
+;in r16,TCCR1B
+;cbr r16,ICES1
+;out TCCR1B,r16
+
+; build the byte ;) - still wrong!
+ori r21,1
+lsl r21
+
+;
+; hier gehts weiter ...
+;
reti