 |
| Author |
Message |
|
|
Posted: Mar 01, 2012 - 01:33 PM |
|

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...... |
|
|
| |
|
|
|
|
|
Posted: Mar 01, 2012 - 01:53 PM |
|


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? |
_________________
|
| |
|
|
|
|
|
Posted: Mar 01, 2012 - 01:59 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Mar 01, 2012 - 02:06 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Mar 01, 2012 - 02:07 PM |
|


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! |
_________________
|
| |
|
|
|
|
|
|
|