Society of Robots - Robot Forum

Software => Software => Topic started by: spizzak on September 22, 2011, 10:03:45 AM

Title: Atmega8 Clock Question
Post by: spizzak on September 22, 2011, 10:03:45 AM
Can anyone tell me what the Atmega8 is clocked at by default, and how to set the fuses to use an external oscillator?

Also, I have a board that has an oscillator on it but I'm not sure if the chip was configured to use it. Is there anyway to check what freq it's running at?
Title: Re: Atmega8 Clock Question
Post by: joe61 on September 22, 2011, 04:39:27 PM
The data sheet is at http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf (http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf)

In the section "System Clock and Clock Options" it says that the factory default is 1MHz. If you're using avrdude to program the part, the option to set the low fuse byte is -U lfuse:w:<value>:m

The <value> part of that specifies the bits you want to set, and must be given as a hex number prefixed by '0x'. Read the section in the data sheet called "Memory Programming" to see what the options are. I won't give you a value because putting the wrong thing there could make the chip unresponsive. Read the section carefully and decide what you want it set to.

You can check the current setting of the lfuse byte with avrdude by doing the following - this is with an atmega328p, and using a USBtiny programmer:

Code: [Select]
opus$ avrdude -c usbtiny -P usb -p m328p -t

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude> dump lfuse
>>> dump lfuse
0000  e2                                                |.               |

avrdude> q
>>> q

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

The value 'e2' shows what bits are set in the lfuse byte.

Edit: I noticed in the other thread about this that you're using AVR Studio. Can't help you there, sorry.

Joe
Title: Re: Atmega8 Clock Question
Post by: joe61 on September 23, 2011, 05:43:54 PM
I ran across this and thought you might find it useful. I haven't used it, but it was linked to from a reliable source ...

http://www.engbedded.com/fusecalc/ (http://www.engbedded.com/fusecalc/)

Joe