timers

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

in timer 1 of 16 bit timers of atmega 2560 .

if i write

TCNT1H =0xec

TCNT1L=0x01

OCR1AH = 0x02;   
 OCR1AL = 0xFF;

 ICR1H  = 0x02;    
 ICR1L  = 0xFF;

TCCR1A = 0xAB;// fast pwm ..mode 14, non inverted output

TCCR1B = 0x0C;// prescalor 256

so here timer 1 is initialized for 10 bit pwm mode ,n=256,with my TOP = ICR1=ox02ff=767

and if i initialize TCNT1 =0xec01=60417.

So now will my counter always start from 60417 ( as i have loaded tcnt1 with that) ..so conter will go from 60417 to 65535 and then to 0 and then from 0 to 767 ( which is it top value). and then TOV flag will be updated ( as timer has reached top and mode 14 is selected).?????

 

main confusion to me is that i i load tcnt1 then will my timer will start from that value ?????

and then after top it will again overflow and 

 

 

Kunal Gupta

github.com/gkunalupta

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
TCCR1B = 0;     //stop the timer
TCNT1 = 60417;
OCR1A = 767;   
ICR1  = 7672;    
TCCR1A = 0xAB;// fast pwm ..mode 14, non inverted output
TCCR1B = 0x0C;// prescaler 256

We don't know as your code doesn't specifically stop the timer first. 

Last Edited: Sat. Feb 8, 2020 - 09:39 AM