Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- light dimmer na nekom pinu pomocu timera, tako da se intenzitet svijetla mijenja promjenom omjera popunjenosti (DC-om),
- treba priložiti proračun svega
- */
- .def tmp = r16
- .def step = r17
- .def ocval = r18
- .equ delayCnt = 10
- .cseg
- rjmp reset
- reset:
- ldi tmp, high(RAMEND)
- out SPH, tmp
- ldi tmp, low(RAMEND)
- out SPL, tmp
- ldi tmp, 0x03
- out PORTB, tmp
- ldi tmp, 0
- out DDRB, tmp
- ldi tmp, (1 << PD5)
- out DDRD, tmp
- ldi tmp, (1 << COM1A0) | (COM1A1) | (1 << WGM10)
- out TCCR1A, tmp
- ldi tmp, (1 << WGM12) | (CS11)
- out TCCR1B, tmp
- ldi tmp, high(128)
- out OCR1AH, tmp
- ldi tmp, low(128)
- out OCR1AL, tmp
- ldi ocval, 0x00
- ldi step, 0x0A
- main:
- sbis PINB, 0
- rcall smanji
- sbis PINB, 1
- rcall povecaj
- rcall delay
- rjmp main
- smanji:
- ldi tmp, 248
- in ocval, OCR1AL
- cpse tmp, ocval
- add ocval, step
- out OCR1AL, ocval
- ret
- povecaj:
- ldi tmp, 8
- in ocval, OCR1AL
- cpse tmp, ocval
- sub ocval, step
- out OCR1AL, ocval
- ret
- delay:
- push r17
- push r18
- push r19
- clr r17
- clr r18
- ldi r19, delayCnt
- delay_loop:
- dec r17
- brne delay_loop
- dec r18
- brne delay_loop
- dec r19
- brne delay_loop
- pop r19
- pop r18
- pop r17
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement