Internal RC Oscillator for UART

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

Hi all,

I read that using internal RC oscillator is not reliable when "timing accuracy" is needed. I am using tiny2313, and I need to use uart at 2400 baud rate, does this application require "timing accuracy"? :?: I prefer to use internal RC oscillator to leave XTAL pins as I/O.

How can you define timing accuracy?
How does operating temperature effect 8 MHz internal RC oscillator?

Thank you in advance...
Mehmet

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
How can you define timing accuracy?

For RS-232, it must be within 2% accuracy. The internal oscillator can be as much as 10% off, so unless you correct that one way or another, the internal oscillator is not accurate enough. If you calibrate the internal oscillator, you may be able to get it accurate enough depending on your circumstance. If you are going to have a stable voltage and a relatively stable operating temperature, it may work for you.

Quote:
How does operating temperature effect 8 MHz internal RC oscillator?

There is a graph of this in the datasheet.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is also a good article about clock sources in the Articles section of AVR Freaks: Why you need a Clock Source is the title.

Regards,
Walt
____________________________________
"Nothing in this book is true."
-Cat's Cradle

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Application note AVR053 shows how to do a 'one time' calibration of the internal RC oscillator with your STK500 (hope you have one!). Works very reliably. T
here are some other ways to calibrate dynamically to break or sync characters send by a PC. If temperature and/or supply voltage change considerably (ok, what does that mean? Look into the data sheet!) during operation you might want to go the second way.
I found that AVR053 works for me and with some tricks you can even calibrate for different supply voltages (running an RTC on Lithium battery @~3V or running @ 5V from a normal voltage regulator).

Jörg.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
does this application require "timing accuracy"?

Yes. But not absolute timing accuracy ... it requires "relative timing accuracy."

The microcontroller must remain in sync for all of the bits sent or received in each word transmitted. Assuming that synchronization is performed at each start bit, assuming that each frame includes 1 start bit, 8 data bits and no parity, and assuming that synchronization is performed with a precision of one sixteenth bit time, then a receiver must be able to take 9 samples in the approximate range of 8.56 to 9.44 bit times. This means that the relative frequencies of the sender and receiver bit clocks must be within about -4.9% to +4.9% of each other.

You will often see the suggestion that the serial bit clock be within 2% of a nominally selected bit rate (such as 2400 bits per second). This ensures that combining the bit rates from transmitter and receiver does not exceed approximately 4%. So long as the relative bit rates are close enough to each other, it doesn't matter what the nominal bit rate is -- even if it is some odd rate like 2640 bits per second. And the ATtiny2313 can support a variety of common as well as odd bit rates with its programmable 12-bit baud rate generator.

Quote:
I prefer to use internal RC oscillator to leave XTAL pins as I/O.

You can use the internal RC oscillator.

In order to be successful, you must ensure the a reasonably accurate relative bit rate between the transmitter and the receiver. It is true that the frequency of the internal RC oscillator may not be very well known in absolute terms, but it is very stable for short periods. How can your ATtiny2313 determine the bit rate of the data it is receiving? The answer is autobaud.

If the device on the other end of the serial line were to send a known character that precedes each packet of information, then your microcontroller could time the bits of that character to determine the approximate number of AVR clocks each bit time takes. This is precisely the information needed to set the baud rate generator in the microcontroller. This rate can be used for reception and transmission over short periods. If a long period is expected between a receive and a subsequent transmit from the AVR, then you may need to additional transmissions to the AVR to ensure it remains at the proper bit rate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for your suggestions.
I am going to try it (I have STK500)...