Pages: [1]   Go Down
Author Topic: Everything seems 10 times slower on Atmega168...  (Read 1168 times)
0 Members and 1 Guest are viewing this topic.
Auckland
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Web Developer going physical interface Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
« Last Edit: June 19, 2011, 12:00:52 pm by timb0 » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-wink

Lefty
Logged

Auckland
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Web Developer going physical interface Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Leeds, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Take a look here for a fuse calculator -

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

Auckland
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Web Developer going physical interface Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Auckland
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Web Developer going physical interface Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink

thanks so far !!
Logged

Portland, OR
Offline Offline
Full Member
***
Karma: 0
Posts: 101
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Auckland
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Web Developer going physical interface Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Portland, OR
Offline Offline
Full Member
***
Karma: 0
Posts: 101
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Certainly sounds like it to me.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6649
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the right fuse settings
For various arduino-like boards, the "correct" fuses are listed in the .../hardware/arduino/boards.txt file
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4258
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Auckland
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Web Developer going physical interface Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

The default fuses is Just what I needed.

Now I have no more problems Wooo~!

thanks smiley
Logged

Pages: [1]   Go Up
Jump to: