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
himel1842
PostPosted: Mar 01, 2012 - 01:33 PM
Rookie


Joined: Oct 28, 2011
Posts: 26


Dear all,thanks for being so helpful. I am having some confusion with USART data rate.If I set USART baudrate to 19200 with 8MHz external crystal the time of output wave from USART Tx pin which I see in oscilloscpe is like 70us(ontime, so total time is like 140us). Can you please explain me how it works? If I do 1/F of 19200 it's suppose to be 520us. I think I am missing some basics here......
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 01, 2012 - 01:53 PM
10k+ Postman


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

Quote:

If I do 1/F of 19200 it's suppose to be 520us.

Not on my calculator - it says (roughly) 52.083us. If you are measuring 70us it suggests the CPU is slower than you think. Did you get the UBRR value right?

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
david.prentice
PostPosted: Mar 01, 2012 - 01:59 PM
10k+ Postman


Joined: Feb 12, 2005
Posts: 16308
Location: Wormshill, England

I seldom measure things. It is as easy to calculate
UBRR = 8000000 / 16 / 19200 - 1
Code:
UBRRH = 0;
UBRRL = 25;

Bit-time should be 52us. A byte of 8-N-1 is 10 bits, which will take 520us.

David.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
himel1842
PostPosted: Mar 01, 2012 - 02:06 PM
Rookie


Joined: Oct 28, 2011
Posts: 26


Sorry for typing mistake. Yes it is 52us. I am getting 70us from oscilloscope.Still not matching. UBBR value seems Ok. Again I will check with different values. Thanks.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 01, 2012 - 02:07 PM
10k+ Postman


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

If it really were 70us with UBRR=25 then it suggests the CPU is running at 5.942MHz which is a very odd speed indeed!

_________________
 
 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