Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Need to set 20 MHz external crystal to work with Atmega328P

Status
Not open for further replies.

alfie.max15

Member level 2
Joined
Jan 3, 2013
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,660
I have been working with my micro-controller for the last 2 months and i have had a bitter experience while setting fuse bits. I had to throw away one...

So now i need to work with an external clock of 20Mhz

i have got a 20MHz crystal and while reading the datasheet i have learned i need to connect it to the xtal1 and xtal2 pins of the uC. and i know that i need to use 22pF capacitors on both pins and then put them to ground...

But i dont know the part where i need to tell the uC that it has to work off the external clock

But even after searching the net and reading the datasheet i am not confident enough to try setting the fuse bits to make my uC work with external clock.

Could anyone here help me out? i really need to do this and after this i do have a few more doubts about this... But first can anyone pls help me set my uC to work with 20MHz crystal
 
Last edited:

try with ponyprog
apply 1Mhz external clock with ground reference to xtal1 pin.
you can easily recover the wrong fuse settings.
 

Attachments

  • Capture.PNG
    Capture.PNG
    63.8 KB · Views: 213

Thank you guys so much for helping me understand about resetting fuse bits...

But what i want to achieve here right now is...

I want my atmega328P uC to work with 20MHz crystal
https://www.nex-robotics.com/products/electronic-components/crystal/20mhz-half-size.html

so i know i need to connect them across the XTAL1 and XTAL2 pins of the uC... and with 22pF capacitors connected on each pins and grounded...

6879517700_1362761389.jpg


so now i need to know what fuse bits has to be set...
how to set them?
and the circuit to set it... i mean while setting the fuse bits should i connect the crystal?
 

Crystal will be always connected if you use an external crystal. You set fuses through software. Which compiler are you using and what programmer software are you using? You have to set the clock frequency and other fuse bits in the Compiler or code.
 

Why are you not using the programming software that is provided by Nex Robotics? Both the programming software has options to do fuse settings.
 

Why are you not using the programming software that is provided by Nex Robotics? Both the programming software has options to do fuse settings.

i cant use that cos it doest have the Atmega328P listed in its drop down list of all the uC's it can program..
 

**broken link removed**

this is the one that i use... and yes it supports Atmega328P
its just a GUI version of avrdude....

and it does have all options to read fuses and write fuses... but i dont understand what value to set... etc..
 

The program you use has already a graphic interface to make the options.
For 20MHz use
m328.jpg

The CKDIV8 is enabled by default and divides the clock by 8, you can either change the fuse of change it in the code of your application

There is also useful fuse calculator you can use
https://www.engbedded.com/fusecalc
 

I didn't ask that. What I asked is whether your USB programmer (Hardware) supports ATMega328P chip programming?

Yes it does... i have been working with the programmer and Atmega328P for the past 2 months... and yes i am able to program my uC with that hardware...

- - - Updated - - -

There is also useful fuse calculator you can use
https://www.engbedded.com/fusecalc

Thanx for this link.... but i dont understand this...

if i want to use the 20MHz crystal...

there is just too many options in the drop down menu for features...

which one should i select...?
 

Depending on the option you make the fuses change too.
Select the full swing crystal oscillator tab as shown in my image and use the shown settings.

An alternative way is to enter the high and low fuse valued directly in the hex fuse editor tab
fuse_hex.jpg

use the online calculator I have posted for the correct values
 

Prob solved....:)
Now i got my Atmega working on external crystal

Thanx for all your quick help...:)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top