Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TurnLedsOn:
- ldi r16, (1 << OCIE1B) ;set compare interrupt
- sts TIMSK1, r16 ;set timer interrupt
- ;set ocr1b to 15625
- ldi r16, 0x3D ; high
- sts OCR1BH, r16
- ldi r16, 0x09 ; low
- sts OCR1BL, r16
- sei ;enable interrupts
- ldi r17, 0 ;interrupt counter
- ldi r18, 0 ;will change led state
- ldi r19, 1 ;led state 1 if on
- ldi r16, 0
- sts tcnt1h,r16 ;zero to counter
- sts tcnt1l,r16 ;zero to counter
- ldi r16, (1<<cs12) ;prescaler 256
- sts tccr1b, r16 ;start timer
- cbi PORTB, 7 ;turn diode on
- Loop:
- cpi r18, 1 ;should change state
- breq Blink ;if true jump to blink
- Continue:
- cpi r17, 3 ;should end
- breq End
- jmp Loop
- Blink:
- cpi r19, 1 ;if led on
- breq TurnOff ;jump to on
- jmp TurnOn ;jump to on
- TurnOn:
- cbi PORTB, 7 ;turn on led
- ldi R19, 1 ;state led on
- ldi R18, 0 ;should change false
- jmp Continue
- TurnOff:
- sbi PORTB, 7 ;turn led off
- ldi R19, 0 ;state led off
- ldi R18, 0 ;should change false
- ldi R16, (1<<cs11)|(1<<cs10) ;prescaler 64
- sts tccr1b, r16
- ;set ocr1b to 31250
- ldi R16, 122
- sts ocr1bh, r16
- ldi r16, 17
- sts ocr1bl, r16
- jmp Continue
- End:
- rjmp END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement