- 9


rjmp RESET

.ORG $10

RESET:

ldi temp,low(RAMEND)

out SPL,temp

ldi temp,CDDRB ; put in/out

out DDRB,temp

ldi temp,CDDRD

out DDRD,temp

ldi periodl,low(FIRSTFREQ) ; put Initial frequency

ldi periodh,high(FIRSTFREQ)

ldi temp,PUTTCCR1B ; put CK

out TCCR1B,temp

sbi PORTB,4 ; extinguish diods

sbi PORTB,3

ldi flag,0b00000001

ldi smallth,0

ldi smallth,0

ldi temph,0

ldi templ,0

rjmp MAIN

RSTTIMER: ; reset's counter

ldi tempi,0

out TCNT1H,tempi

ldi tempi,0

out TCNT1L,tempi ;RESET timeout timer

ret

WAITMATCH:

ldi temp,0b01000000 ; 7

out TIFR,temp

LOOP:

in temp,TIFR; wait for matching flag

sbrc flag,2

rjmp LOOPT

in tempi, TCNT1H; 1/4

cp timeh,tempi

breq P

in tempi, TCNT1H

cp timeh,tempi

brlo EXIT

LOOPT:; , +1/4

sbrs temp,6

rjmp LOOP

EXIT:

ret

P: ;

in tempi, TCNT1l

cp tempi,timel

brlo LOOP

ldi flag,1

cp tempi,timel

brge EXIT

DIV: ; divide in 4

sec

clc

ror temph

ror templ

clc

ror temph

ror templ

ret

FIRSTOPT: ; process the first diode

sbi PORTB,3 ; light the diode

in templ,TCNT1l

in temph,TCNT1H