168 Bootloader Error

That's what I thought. As for the 168 chip, could it be that while trying to use AVR studio I set some kind of fuse to require an external oscillator? I think I saw someone with that problem on AVR freaks. If it's dead then I'll just have to get another one I suppose.

If you're trying to run the ATmega168 at 20 MHz, then, yes, you need an external oscillator. It's likely that you've set the fuses to require one, as most of the documentation tells you to, and the scripts do so.

I was hoping that because the chip gets it's clock from the programmer during programming, I could still use the arduino007 environment to program it. It's likely that I screwed up the order and set the fuses to take a 20MHz clock before I updated the bootloader. Now I can't get the chip to talk to anything. I don't know how to set the fuses back or get the updated bootloader on there. Any ideas?

If you set the fuses to take a 20 MHz clock, you need to connect it to a 20 MHz clock (or a 16 MHz clock).

I haven't built any kind of USB or serial interface for the breadboard. Even if I did, all I've got are oscillators and not an actual external clock. I think it's time to just get a new chip and start using the new make file from the very beginning.

Sorry, the oscillators should be fine. Do you have an Arduino board? If so, the chip should work in that, since it has the 16 MHz oscillator/clock.

ya, I have the arduino usb board with the built in 16Mhz clock. It was working in that until I tried to put the new bootloader on it. I don't think I even got the new recompiled bootloader on there before I did something to break the chip and prevent anything from connecting to it.

Hi amsmnptarks,

I got a 20 MHz bootloader loaded successfully on a 168 on an Arduino NG. I compiled the same thing you did, then put it on a virgin 168 using AVRStudio and my Dragon. I moved the chip to an Olimex P28 with a 20-MHz crystal, and it ran and I was able to download a program to it. However, when that program tried to do serial output to my PC, it didn't work - obviously the clock messed up the baud rate. I run Arduino on my P28 all the time at 16 MHz and it works fine - maybe I'm forgetting something.

It would be nice to be able to use all the speed the 168 is capable of! I'm not sure if this would work on the Arduino board if I changed the crystal - I didn't want to unsolder it.

D.

Once you get the fuses set right youl breze through the rest. Youve just got to make sure youve got the right file after that. Try find a toutorial based on the software your useing. I can send you a 168 with a bootloader on it for 7.00 or you can send me your chip and $2 to program for you if you like. The offer stands for anyone who needs it. Im in the high power rocketry club and we should have a section set up on our website for this offer soon. (www.ncsuhpr.co.nr). We now have paypal too :sunglasses:

Joshua McCoy
jjmccoy@ncsu.edu
aerospace engineering student
NCSU

drd: did you change the build.f_cpu setting in your Arduino preferences file? Otherwise, the Arduino sketch will expect to run on a 16 MHz clock, and the serial timing will be off. See: http://www.arduino.cc/en/Hacking/OtherHardware

Thanks, mellis! That was it - now everything works fine at 20 MHz.

I am having a hard time find exactly how to burn the bootloader. I have a STK500 board, Arduino with 168. Having the STK500 seems to be an advantage but I can't find the what fuses need to be set and should I use AVR studio or AVRdude or the Arduino software. I have all the tools I just need some help getting this done.

thanks

...Having the STK500 seems to be an advantage but I can't find the what fuses need to be set...

Try this tutorial, and this one too

D

Thank alot the first Tutorial was very helpful.

I am having some timing issues with the 168. is the native speed 8mhz? because it seems that it is not 16Mhz. I am porting Atmega8 code to a 168

thanks for the help

If you haven't set the fuses properly, the ATmega168 could be running of its internal clock: either at 1 MHz or 8 MHz.

Hi neuromancer,

I soldered a 20 MHz crystal on an Arduino NG and it works fine. If you need the .hex file for a 20 MHz bootloader I can send you one or post it here.

Using AVR Studio, all you need to do is:

  1. Set the lock bits to unprotected
  2. The fuses should all be UNPROGRAMMED == 1 except:
    Boot flash size = 1024 (BOOTSZ = 0)
    Boot reset $0000 (BOOTRST = 0)
    Brownown detection disabled (BODLVL = 111) (unprogrammed == 1)
    Clock = external 8- 14CK + 0 (CKSEL = 1111 SUT = 00) - you need to scroll right to see the CKSEL etc...

Program that, then program your bootloader .hex file.

  1. Finally, set the lock bits to 0xCF to protect the bootloader.

This works fine with my Dragon, if you are using serial ISP, I don't know.

The only hiccup I had was I needed to set my frequency to 125 KHz in the "BOARD" menu. My cable may be too long.

Good luck!

D.

I used the fuse setting in the tutorial above.
20Mhz is not really that important to me.

Would this set the Freq to 16Mhz?
Ext. Crystal Osc.; Frequency 8.0 - MHz; Startup time PWRDWN/RESET: 16K CK/14 CK + 0ms; [CKSEL=1111 SUT=0]

It could be something to do with the Timer registers because they are named differently in the 168. I have not investigated it fully yet.
But if the fuse settings are correct then I can rule that out as the problem.

Thanks

Yes, the fuse settings are the same for 16 or 20 MHz - only the boot loader is different. Your CKSEL and SUT are the same as mine. And yes, the fuses are quite different for ATMega 8 and 168, and there is the extended fuse on the 168.

This stuff was very confusing to me but I finally got it working. I'm glad to help any way I can.

Now I'm dreaming of Arduino on the 324, 644 and 128 - wouldn't that be fine?

D.

I'm glad to help any way I can.

Write it down in a way that every n00b can understand and post it on the playground.