.include "../tn13Adef.INC"
.def a=r16
.org $0000 ; startup vector
rjmp onReset
.org $0006 ; compare match vector
rjmp Tim0CompA
onReset:
sbi DDRB,0 ; port B0 as output
ldi a, 0b10000011 ; pwm mode 3
out TCCR0A, a
ldi a, 0b00000101 ; divider /1024
out TCCR0B,a
ldi a, 0b0000100 ; enable compare interrupt
out TIMSK0,a
sei
main:
rjmp main
Tim0CompA:
in a, OCR0A
inc a
out OCR0A,a
reti
if we set divider to 8
ldi a, 0b000000010 ; divider /8
out TCCR0B,a
and edit the timer routine to
we'll get smoother PWM respond
Tim0CompA:
in a, OCR0A
dec a
out OCR0A,a
reti
we'll get smoother PWM respond
with prescaler 64
prescaler 256
with prescaler 64 and increasing OCR0A
No comments:
Post a Comment