Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
GBaars
PostPosted: Dec 06, 2013 - 04:08 PM
Hangaround


Joined: Jul 23, 2004
Posts: 111


For pwm measuring timer1 is
started and stopped like (below).
After stop TCNT1H:L are read.


;stop
clr r16
sts TCCR1B,r16

;start
clr r16
sts TCNT1H,r16
sts TCNT1L,r16
ldi r16,1
sts TCCR1B,r16

Is this ok for timer1


Last edited by GBaars on Dec 06, 2013 - 08:23 PM; edited 1 time in total
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
theusch
PostPosted: Dec 06, 2013 - 04:15 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 28967
Location: Wisconsin USA

Except for the typo, it looks OK.

For precise work, PWM measurement would be done using the Input Capture facility (ICP) and the ICP1 pin.
 
 View user's profile Send private message  
Reply with quote Back to top
Visovian
PostPosted: Dec 07, 2013 - 07:03 AM
Posting Freak


Joined: Aug 07, 2007
Posts: 1834
Location: Czech

Quote:
sts TCCR1B,r16
Is this ok for timer1
Depends on avr type.
Ok for Atmega88 (TCCR1B adr=0x81)
but for Atmega8 (TCCR1B adr=0x2E) it writes to a wrong address without warning .

I allways use OUT and if I get a warning I rewrite to STS.
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Dec 07, 2013 - 08:34 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 22026
Location: Lund, Sweden

And then there are the macros that select between STS and OUT automagically.

Just wait for John to pass by and he'll point them out. Wink

_________________
"Some questions have no answers."[C Baird]
"There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson]
"There are always ways to disagree, without being disagreeable."[E Weddington]
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Dec 07, 2013 - 09:59 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71189
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

Just wait for John to pass by and he'll point them out.

It's AVR001 isn't it?

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits