Go Down

Topic: Everything seems 10 times slower on Atmega168... (Read 1 time) previous topic - next topic

timb0

Jun 19, 2011, 06:49 pm Last Edit: Jun 19, 2011, 07:00 pm by timb0 Reason: 1
Hello, so I've got a couple little Atmega168 chips given to me (3.3 volts I think as it is set with a jumper to choose the input voltage - I'm using 5v) This has been flashed clean it seems so I've been through the process of getting a programmer kit over USB (UsbTiny) and have been able to load a sketch onto it. However, when I do the simple blink (in my case I made it do a delay 300 instead of 1000) the led blinked for 3 seconds on then off for 3 seconds! I thought this was odd, and thought it had something to do with the crystal, I removed it for a joke and it didn't change anything? I don't know if that's relevant or how to troubleshoot this, It's taken me a long time to get this far...

I would like to know if anyone knows what may cause this and how to fix it? I have 2 8MHz crystals and swapped them around and I don't think they're both broken but ya never know...

Is it something to do with the fuses perhaps? How do I ensure I get the right one, I haven't set or changed any fuses on this chip though...

Thanks heaps for any help :)

retrolefty

Quote
Is it something to do with the fuses perhaps? How do I ensure I get the right one, I haven't set or changed any fuses on this chip though...


Yes it's all about the processor chip's fuse settings. Your chip is setup (via the fuse settings) to utilize a slower internal RC clocking source built into the chip. Changing the fuse setting will force it to utilize an external wired crystal or resonator and run at the speed of the crystal. Changing fuse settings is a somewhat complex procedure and I can't provide you with the specific steps you will need, but at least you now understand the situation.  ;)

Lefty

timb0

Wow, I'm not as stupid as I thought :p

I'm looking into it now, any one with knowledge on how to ensure I get the right fuse settings ?

a.d

Take a look here for a fuse calculator -

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

timb0

Thanks,

I've been playing with the calculator, though each time when I write a fuse it gives me an error (i've tried a few different settings too):

Writing |                                                    | 0% 0.00s ***failed;
Writing | ################################################## | 100% 0.05s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xf9:
avrdude: load data efuse data from input file 0xf9:
avrdude: input file 0xf9 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xf9 != 0x01
avrdude: verification error; content mismatch

avrdude: safemode: efuse changed! Was f9, and is now 1
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

timb0

Hmm, I've had some success now,

I un-ticked the option:

Divide clock by 8 internally; [CKDIV8=0]

And now it's blinking the way I'd expect.. Though I really don't know about the failed bits being written in the fuse, nor which settings I should be choosing, I just tried heaps of them till I got it to work, but now each one I try as long as that option is un-ticked and I choose an 8MHz crystal it works... probably a really silly way to do it but I got 2 chips so am prepared to mess one up for learning ;)

thanks so far !!

growler

Just so you know, in the future just guessing and burning fuses may leave you with a chip that is hard to recover but it sounds like you were prepared for that.

Chips from the factory are set to look at the internal 8mhz internal oscillator with a clock prescaler that brings the clock speed down to 1 MHz.

You still might not be using an external crystal if you just changed the prescaler.

timb0

Yes thanks, I am prepared, and I also read what to do if I totally mess it up (which had something to do about creating my own external 1 mhz clock externally to kick it into life sortta thing.) but I should read the instructions carefully (only there aren't any easy to understand ones I can find :p)

I did test that it was using the crystal as I removed it while it was running and everything stopped, then plugged it back in and it started again so that must mean I'm using the crystal right?


westfw

Quote
the right fuse settings

For various arduino-like boards, the "correct" fuses are listed in the .../hardware/arduino/boards.txt file

floresta

Quote
Take a look here for a fuse calculator -

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


And also look here for the Arduino default fuses: http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/

Don

timb0

Thanks,

The default fuses is Just what I needed.

Now I have no more problems Wooo~!

thanks :)

Go Up