Fuse bits for selecting EXTERNAL CRYSTAL OSCILLATOR for ATMEGA168A?

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

Can any one please explain the ways in which atmega chip can be clocked for example difference between ceramic resonator and normal crystal oscillator we found on arudino(16Mhz), external clock etc. PLEASE SEE THE ATTACHMENTS WHERE I INCLUDED SEVERAL TABLES THAT CONFUSES ME FROM AVR DATASHEET..

It's really confusing and even on internet no correct and straight forward simple explanation.

Consider I want to use 20Mhz crystal oscillator (normal one as like arudino's 16Mhz) to clock my avr. What fuse bit should I select. I attached a screenshot of a table from datasheet, please any explain what all those low, high medium power means plus do they really mean using normal CRYSTAL OSCILLATOR?

My doubts topic are listed below:

1.What is really this ceramic resonator means?? Difference between it and a normal crystal oscillator we use??

2. Low power crystal oscillator and Full swing crystal oscillator? Do I really choose Full swing crystal oscillator since I need a clock of 20Mhz??

3. Also explain Ceramic resonator_fast rising power, Ceramic resonator_slowly rising power all this thins means. I will include the screen shot of each area which is to be explained?

Attachment(s): 

avr freaky

Last Edited: Tue. Aug 13, 2019 - 02:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Forget about ceramic resonator, don't even look at it.  Ceramic resonators are lower cost/less accurate replacements for crystals...before China came along, crystals used to be $$$ and you might save 50 cents by using a resonator.  Now crystals are a nickel, so who cares.

 

Many of the entries are concerned with how long it takes the clock to get up to speed and stabilize...for some critical apps that is important (such as coming out of sleep and performing some timing operation), for many & yours it likely doesn't matter...you can always put in a  delay at the begiinning, or select the longest startup option. 

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

2) 20MHz (and indeed anything over 8MHz) = Full Swing

 

3) crystal resonation is a bit like that thing you can do when you run a wet finger around the rim of a cut crystal glass and after a while the class starts to "sing". As you will know you have to drag your finger around a few times before the glass starts to resonate. Crystals on micros are like this too (also think of swinging a heavy pendulum like a child's swing to get it to "oscillate"). These things take time to get going. So you want to say to the AVR - start the crystal going but give it a while to "sing". That is "Start Up Time" (SUT). Unless you can think of a reason why it must be otherwise (unlikely) then set this to the longest option possible which, in all likelihood, is 64 milliseconds.

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

If you have doubts about setting fuse bytes, I suggest checking if the microcontroller you are using is avaliable in the site http://www.engbedded.com/fusecalc/. This site abstracts all fuse settings and parameters from the chip in a more "begginer friendly" way than the datasheet. You can either chose the settings you wish to load and the site will give you the corresponding fuse values or you can indicate the fuse value and the site will tell you what it stands for.

 

Allthough this is a usefull tool, there are a lot of chips that are not avaliable in it. That's why you should practice reading the datasheet and beeing able to understand those tables. It's confusing at the begging, but worth it.

 

If you see the Extended Fuse (efuse) and the High Fuse (hfuse) tables of this chip, that contain the factory parameters, you will realise you problably don't have to change any of those, unless you need some "special" funcionality like BOD or WatchdogTimer, etc...

 

The fuse byte that usually has to be changed is the Low Fuse (lfuse), in which clock source, frequency and start-up time settings can be selected. If you look at the lfuse table of your chip, you will see the following parameters: Clock divided by 8 (CKDIV8); Clock Output on PB0 (CKOUT); Start-up time (SUT1:SUT0); Clock Source Selection (CKSEL3:CKSEL0). It also says that if you write 1 to those bits, you'll programm it, and if you write 0 you will unprogramm it.

 

So let's do the lfuse selection for your situation: Clock divided by 8 disabled (CKDIV8 = 1); Clock Output on PB0 disabled (CKOUT = 1); Start-up time, seeing the table 9-6 on page 40 (full swing crystall oscillator - optimized for frequency ranges that go above 16MHz), in that table, it's recommended that you choose the slowest star-up timer and delay, because it avoids inicializing issues unless you need a really quick start-up, so Crystal Oscillator, slowly rising power 16K CK 14CK + 65ms 16CK (SUT1:SUT0 = 11); Clock Source Selection, in table 9-1 page 37, you can see the values of CKSEL for each source, so for full-swing crystal it needs to be between 0111 and 0110, in table 9-5 page 40 you can see that this micro does not have different fuse setting for optimazing the clock frequency (so you have CKSEL0 = 1 because of the SUT setting we've choosing and CKSEL3:CKSEL1 = 011).

 

Putting it all together, lfuse = 11110111 (converting to hex it is 0xF7, avrdude command: -U lfuse:w:0xF7:m). If you select those parameters in the site I've mentioned, you'll see that it will match.

 

Keep in mind that those tables can change. They are usually similiar, but a small change can make you select the wrong clock source, beeing unable to communicate with the device without connecting the proper clock. That's why it's important to aways check the datasheet.

 

Roga.

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

Beware: External crystal DOES NOT EQUAL External Oscillator. You need to pay close attention to the names of the CKSEL fuse settings.

 

External crystal is the external resonator (typically 2 "pins") usually with two capacitors in the 12pf-24pf range. External (crystal) oscillator is usually 4 pins and requires power to function. The latter will create a clock signal even if there is no micro.

 

The one you DO NOT want is "External Oscillator".

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Beware: External crystal DOES NOT EQUAL External Oscillator. You need to pay close attention to the names of the CKSEL fuse settings.

I believe you are correct & wrong at the same time...correct from a common sense & logical standpoint.   However, Studio & the datasheets are sometimes neither.

 

Unfortunately some dodo decided to "blend" the names in the Studio selections.  So instead of saying  "crystal" (2 pin device)  or saying "oscillator" (4 pin signal source), they "smartly" use the term "crystal oscillator" in their selections (meaning 2 pin).   The 4 pin signal source  (oscillator) is "ext clock source" .

 

 

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

Last Edited: Tue. Dec 17, 2019 - 09:08 PM