Timer/counter 2
hi every one,
i trying use timer/counter 2, output (oc2a) following code :
ddrd |= (1<<pb3);
// timer 2 activation
prr &=~(1<<prtim2);
// timer/counter2 clocked i/o clock
assr &=~(1<<as2);
//set initial timer value
tcnt2=0;
//place top timer value output compare register a
ocr2a=255;
// set fast pwm mode
// , make toggle pb3/oc2a pin on compare match
tccr2a |=(1<<com2a1);
tccr2a |=(1<<com2a0);
tccr2b |=(1<<wgm22);
tccr2a |=(1<<wgm21)|(1<<wgm20);
// set prescaller 1024 , start timer
tccr2b |=(1<<cs22);
tccr2b |=(1<<cs21);
tccr2b |=(1<<cs20);
// ocie2a: timer/counter2 output compare match interrupt enable
timsk2 |=(1<<ocie2a);
with no success.
the oscilloscope on pin pb3 (oc2a) (arduino pin 11) shows no signal @ all.
what wrong or missing code ?
thank help.
i trying use timer/counter 2, output (oc2a) following code :
ddrd |= (1<<pb3);
// timer 2 activation
prr &=~(1<<prtim2);
// timer/counter2 clocked i/o clock
assr &=~(1<<as2);
//set initial timer value
tcnt2=0;
//place top timer value output compare register a
ocr2a=255;
// set fast pwm mode
// , make toggle pb3/oc2a pin on compare match
tccr2a |=(1<<com2a1);
tccr2a |=(1<<com2a0);
tccr2b |=(1<<wgm22);
tccr2a |=(1<<wgm21)|(1<<wgm20);
// set prescaller 1024 , start timer
tccr2b |=(1<<cs22);
tccr2b |=(1<<cs21);
tccr2b |=(1<<cs20);
// ocie2a: timer/counter2 output compare match interrupt enable
timsk2 |=(1<<ocie2a);
with no success.
the oscilloscope on pin pb3 (oc2a) (arduino pin 11) shows no signal @ all.
what wrong or missing code ?
thank help.
ddrd?
Arduino Forum > Using Arduino > Microcontrollers > Timer/counter 2
arduino
Comments
Post a Comment