| Author |
Message |
|
|
Posted: Feb 23, 2012 - 06:14 PM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
Hi everybody,
I know this has probably been very well said several times
but i wanted to be able to use 16 Mhz external Osciallator and according to the datasheet i think not only i will need to set CKSEL[3..0] to 1000 - 0101 but also i will need to enable CKOPT since i want to use over 8Mhz
I was just wondered if someone could help me understand this better.
I have been reading that it's possible to program fuses bits directly by using ISP just like you would normally bootload the chip. for example a cmd like "avrdude -c usbtiny -p m32" however i don't know which commands to send to the chip. in terms of setting up Low, High & Ext fuses so i can be able to use 16 Mhz.
and if i remember well somebody pointed out that i will need an extra clock signal aswell.
I am using Atmega32 , Winavr and ISP with Usbtiny as a programmer and avrdude to connect to MCU
Any help is very much appreciated
Thanks all. |
|
|
| |
|
|
|
|
|
Posted: Feb 23, 2012 - 06:41 PM |
|


Joined: Jul 18, 2005
Posts: 62941
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
What is wrong with you? This is the second time this week you have created a thread in "Tutorials" that does not belong there. This time I won't offer help and next time I'll just delete the thing. Surely the forum posting rules are clear?
Moderator.
PS Oh well go on then: http://www.engbedded.com/fusecalc/ - that makes avrdude fuse programming almost as easy as using AVR Studio and an Atmel programmer. |
_________________
|
| |
|
|
|
|
|
Posted: Feb 23, 2012 - 06:47 PM |
|


Joined: Sep 04, 2002
Posts: 21394
Location: Orlando Florida
|
|
| Your first message mentions External Oscillator, but then you mention CKOPT, which is used with a crystal, not an oscillator. Oscillators are retangular metal cans as wide as a dip with 4 pins... 5v, gnd, out, and confuse the new guy. Crystals are little cylinders with 2 pins sticking out the bottom. If you really have an oscillator, I think you connect the output to XTAL1. |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 02:18 AM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
Sorry Cliff? if i didn't do this knowingly to be honest,
would you show me where is hould have posted it?
sorry everyone for any inconvenience this might have cause
i didn't recall!
could you show me in which forum i should have post it?
Cheers. |
|
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 02:52 AM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
Let me guess,
I should probably have posted it into AVR GCC forum?
Sorry again everybody,
last time i will try ensuring that each of my topic is well posted!
Is it possible to move it into the appropriate forum?
Cheers. |
|
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 02:56 AM |
|

Joined: Dec 30, 2004
Posts: 9006
Location: Melbourne,Australia
|
|
You've been moved here 'avr forum' bro.
As Bob mentions - there is a difference between an oscillator and a crystal. Select 'oscillator' when you want 'crystal' and things wont work. |
|
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 03:55 AM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
@ Kartman & Bob
Sorry for confusion i might have caused, but yes i meant to say an ext Crystal
but since it also oscillates sometimes i like to say it a crystal oscillator no? even datasheet calls it a Crystal Oscillator right? but of course it's not an RC oscillator.
it's confusion how they all are called oscillators, although one is really a crystal and other an RC. but i think a crystal is nothing more than just an RC but wich probably some more acurate ways. anyway
Thank you for moving the post Kartman.
(i have been searching but i couldn't find it! could you let me know which forum did you transfer to?)
Thanks. |
|
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 04:06 AM |
|


Joined: Nov 22, 2002
Posts: 12196
Location: Tangent, OR, USA
|
|
An External Oscillator is a stand-alone clock maker. You apply power and it makes signal. No micro necessary.
Crystal Oscillator uses an amplifier inside the MCU and and external crystal or resonator. Together, the make "oscillator".
If you choose External Oscillator and try to use a crystal, it does not work. The External Oscillator setting turns off one of the oscillator terminals because only one is needed. So, when you try to hook up a crystal, nothing works.
This is a common confusion, but one that you need to figure out.
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 03:01 PM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
Thank you for your output Jim,
surely i am aware of everything but i probably needed someone to confirm if i am in right track! let's me give you guys a brief of what i will be doing so you could probably point out if something isn't right (I know it's sometimes a hustle to recover the MCU if some of these fuses aren't properly burnt) So:
* I ain't gonna be disabling my JTAG so i will leave JTAGEN still programmed
* Since i want more than 8 Mhz then i will need to set CKOPT at 0, also since i would like to still select the longest delay from start up which is up to 65 ms then i will set SUT[1..0] to 11
* However, I am confused how the table (page 26) works? in facts it doesn't show the range of frequency above 8Mhz?? in steady the next thing it shows is 1<= Could someone make this clear plz? (If i recall correctly Cliff once said something about this table's erroneous??)
* Since Crystal Oscillator Operating Modes makes it clear that when CKOPT is 0 we can choose CKSEL between 101-110-111.
if i then choose it "101" as my CKSEL adding SUT 11 & the rest of BODLEVEL and BODEN unprogrammed (1) then according to FuseCalc. it seems like i will be setting my Low fuse to about 0xFB and High fuse to 0x99 (most importantly on this H fuse ensuring that CKOPT is unprogrammed and JTAGEN programmed)
* So does Lfuse to 0xFB and Hfuse to 0x99 sounds logical guys?
Many Thanks everyone,
Regards. |
|
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 05:29 PM |
|


Joined: Sep 04, 2002
Posts: 21394
Location: Orlando Florida
|
|
| Use the fuse calculator at engbedded.com |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Feb 24, 2012 - 06:05 PM |
|


Joined: Jul 18, 2005
Posts: 62941
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
Use the fuse calculator at engbedded.com
Wish I'd suggested that - oh wait a minute... |
_________________
|
| |
|
|
|
|
|
Posted: Feb 25, 2012 - 04:41 AM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
Thanks.
But yeah that's actually where i got the above results (Lfuse to 0xFB and Hfuse to 0x99) from "engbedded.com"
just the last thing which was probably the most important could you help me about the exact arguments i will be typing in the command line in order to set fuses corrects?
I am using Winavr with avrdude and Usbtiny as my programmer.
If i recall correctly someone here once gave an example such as :
" avrdude -c bsd -p m16 -P lpt1 -U lfuse:w:0xEF:m -U hfuse:w:0xC9:m "
and added that:
* bsd : was the programmer he's been using. which in my case is usbtiny
* lpt1: was also his port. which in my case is usb.
So can I go ahead and use this argument to burn Lfuse to 0xFB and Hfuse to 0x99 accordingly?
" avrdude -c usbtiny -p m32 -P usb -U lfuse:w:0xFB:m -U hfuse:w:0x99:m "
Please help me as i am unsure,
Thank you all. |
|
|
| |
|
|
|
|
|
Posted: Feb 25, 2012 - 09:03 AM |
|


Joined: Jul 18, 2005
Posts: 62941
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
|
|
|
|
Posted: Feb 25, 2012 - 12:25 PM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
Thank you Cliff
I have been googling but i didn't come across your suggested link.
Well... It looks like i were in the right track as both arguments (the one from the site suggests and the other i wrote earlier looks almost the same except some other little modifications)
* The one from " http://blog.spitzenpfeil.org/wordpress/ ... spavrdude/" is
"avrdude -p usbtiny -c m168 -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xDD:m -U lfuse:w:0xFF:m"
I just noticed that in this one there were some little modifications as the avrdude - help says that: "-e" performs a chip erase & "-u" disables safemode.
the confusion in the above argument it doesn't shows the type of port that's been used!! this is being specified by "-P" right?
* So If i were to interpret what the user was trying to do i would say that he was
trying to burn his mega168 to lfuse 0xFF, hfuse 0xDD & efuse 0x00. using Usbtiny as programmer but the port then?? (isn't it necessary?)
* To me without the need of erasing the chip or disabling the safe mode
the argument
" avrdude -p usbtiny -c m32 -U hfuse:w:0x99:m -U lfuse:w:0xFB:m" still look alright!
Could someone point out if I am missing anything.
(I have been asking many questions about this! and i will really be regretting alot if something isn't right afterall I really won't be having time applying other external clock or High voltage programming to recover the MCU back. I just can't afford that time)
Thank you all for your contribution in helping me out.
Regards. |
|
|
| |
|
|
|
|
|
Posted: Feb 25, 2012 - 02:04 PM |
|


Joined: Jul 18, 2005
Posts: 62941
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
I just noticed that in this one there were some little modifications as the avrdude - help says that: "-e" performs a chip erase & "-u" disables safemode.
the confusion in the above argument it doesn't shows the type of port that's been used!! this is being specified by "-P" right?
That's because you don't need -P when using usbtiny - it doesn't have a choice it's always on "usb" so no need to say (though I think it's benign if you want to include "-P usb")
Quote:
but the port then?? (isn't it necessary?)
No, isn't necessary.
If you have an "accident" I have an article in Tutorial Forum about recovering a "locked out" AVR |
_________________
|
| |
|
|
|
|
|
Posted: Feb 25, 2012 - 02:15 PM |
|

Joined: Jan 14, 2012
Posts: 116
Location: New Zealand
|
|
Thank you Cliff.
Really appreciating all the efforts and times
you put in answering others questions
Just to confirm lastly that all these will need to happen
having already a 16 Mhz crystal (with 2x 22pF caps) connected to the MCU?
Thanks again. |
|
|
| |
|
|
|
|
|
Posted: Feb 25, 2012 - 05:29 PM |
|


Joined: Sep 04, 2002
Posts: 21394
Location: Orlando Florida
|
|
| So after this robust compare and contrast discussion of oscillators and crytals, has anyone mentioned what type of AVR is being programmed or did I miss it? Or does it matter? |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Feb 25, 2012 - 05:49 PM |
|


Joined: Nov 22, 2002
Posts: 12196
Location: Tangent, OR, USA
|
|
Processor type does not matter with respect to the difference between "crystal" and "external oscillator". The precise fuses may vary, but the phenomenon of the crystal not operating if you choose "external oscillator: does not vary. AFAIK
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|