- 11


ldi smallperiodl,low(SMALLPERIOD0); put Initial frequency for intermediate pulses for 0

ldi smallperiodh,high(SMALLPERIOD0)

add smalltl,smallperiodl

adc smallth,smallperiodh

out OCR1AH,smallth ; put the time of maching

out OCR1AL,smalltl

rcall WAITMATCH

sbrc flag,0

rjmp EX1

cbi PORTB,4;extinguish the diode

ldi smallperiodl,low(SMALLPERIOD1); put Initial frequency for intermediate pulses for 1

ldi smallperiodh,high(SMALLPERIOD1)

add smalltl,smallperiodl

adc smallth,smallperiodh

out OCR1AH,smallth ; put the time of maching

out OCR1AL,smalltl

rcall WAITMATCH

EX1:

ret

 

SECONDOPT:; process the second diode

sbi PORTB,4 ; light the diode

in templ,TCNT1l

in temph,TCNT1H

add templ,periodl

adc temph,periodh

ldi flag,0b00000100

out OCR1AH,temph; put the time of maching

out OCR1AL,templ

rcall WAITMATCH; wait match

ldi flag,0

cbi PORTB,4;extinguish the diode

 

ret

 

SAVEFAZA:; calculate new period

in templ,TCNT1l

in temph,TCNT1H

rcall DIV

mov periodl,templ

mov periodh,temph

ldi templ,0

ldi temph,0

ldi smallth,0

ldi smalltl,0

ldi timel,0

ldi timeh,0

ret

 

 

 

MAIN:

sbis ACSR,5 ;wait rise

rjmp MAIN

sbrs flag,0

rcall SAVEFAZA

ldi flag,0

rcall WAIT0

rcall FIRSTOPT

 

FALL:

sbic ACSR,5 ;wait falling

rjmp FALL

rcall WAIT1




- -  - -  - -