What's the Use of XTAL in atmega16

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

I want to know the use of xtal 1 and xtal 2...

This topic has a solution.

Salman

Last Edited: Mon. Mar 13, 2017 - 05:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

salmanma6 wrote:
I want to know the use of xtal 1 and xtal 2...

 

Datasheet page 5 and 25.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

This is pretty much general to any micrcontroller/microprocessor; not just AVR - certainly not limited to Mega16!

 

These pins are for connecting an external crystal to give an accurate clock for chip's operation.

 

Having an accurate clock is particularly important for things like Asynchronous Serial (UART) comms.

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:
Datasheet page 5 and 25.

Are you referring to the Full Datasheet, there?

 

Sadly, Microchip seem to have lost that in the rebranding - only the Summary is currently listed on the Product Page!

 

angry

 

See: https://www.avrfreaks.net/comment...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Brian Fairchild wrote:
Datasheet page 5 and 25.

Are you referring to the Full Datasheet, there?

 

Sadly, Microchip seem to have lost that in the rebranding - only the Summary is currently listed on the Product Page!

 

But putting 'mega16 pdf' into a search engine finds it right away...

 

http://www.atmel.com/images/doc2...

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

Brian Fairchild wrote:
putting 'mega16 pdf' into a search engine finds it right away...

Indeed - as suggested: https://www.avrfreaks.net/comment...

 

But it should not be necessary - should it?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

But it should not be necessary - should it?

 

TBH, that's normally how I find any datasheet from any manufacturer. Part number + PDF.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

Brian Fairchild wrote:

TBH, that's normally how I find any datasheet from any manufacturer. Part number + PDF.

 

Yup, and a sad indictment on most vendors' web sites, that it is easier to simply bypass them.

I also use Digikey part search and Data-Sheet-Link, but that sometimes has only one 'data sheet'...

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

Wanted to throw a shout-out to Digikey about their web site.  It's awesome.  Digikey is not always the cheapest, but I shop there because their web site is awesome.  Hope someone from there reads this who isn't a ruthless bean-counter and who appreciates customer service. 

 

S.

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Does the thread title mean "why would you use a crystal?" or very specifically "what is the purpose of the XTALn pins?". You've already been told the use of the pins (usually a crystal across them with each leg grounded via a 10.20pF capacitor to form the external part of a resonant circuit that will then provide pulses (at the crystal frequency) to clock the state logic of the CPU. As to why you would want to do that - it's usually for accuracy. You may need that accuracy if you are trying to interface to some other device in a way that involves both ends running at a "known" speed. Without a crystal it can be difficult to operate at a very accurate "known speed". The other might be for time keeping. Say you want to run the AVR as an alarm clock. If you don't use a crystal (so you use the internal RC oscillator for the clock) it can be as inaccurate as +/-10%. Imagine a clock that gained or lost 10% per day. That means it could be gaining or losing the best part of 2.5 hours every day! A 10% accuracy could also be described as 100,000 parts per million. Compare that to a typical crystal that has an Accuracy of 50 parts per million. Such a clock might gain/lose a maxim of about 4.3 seconds per day. That is a pretty strong reason to use a crystal!

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

Superb!

Salman

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

Another reason to use a Xal is that people use serial lines to attempt debugging (Arduino has "only" UART, no gdb ) and UART need an accurate clock (else, some characters are weird): if a debugging tool (I know there are better) is unreliable, this might exponentiate confusion in unpleasant situations...

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

I also use Digikey part search and Data-Sheet-Link, but that sometimes has only one 'data sheet'...

 

If you do a Digikey parts search the, pdf icons that pop up often connect to the summary datasheet.  If you click on the part number field they will often have links to both the summary & full length datasheets.

Does anyone remember when their "-ND" placed at the end of different part numbers stood for No Discount?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

avrcandies wrote:
Does anyone remember when their "-ND" placed at the end of different part numbers stood for No Discount?
Yep, and many parts did not have the "-ND"; whereas, now try to find one that doesn't!

David (aka frog_jr)