Can I use the ATMega8 on it's own?

Hi,

First, let me apologize in advance for the stupid newbie questions.

I haven't gotten an Arduino board yet because I'm not sure it's what I want. I need to know if once I program the chip I can remove it and place it in a circuit on its own. So, for instance, if I load a program into it that flashes an LED connected to pin 3, can I remove the chip and connect power to the correct pins and an led to pin 3 and have it flash?

If I can do that, I understand that I'll lose serial connnectivity (right?) - what else (if anything) will I lose? LCD drivers?

Thanks for any help!

You can indeed take the chip out of the board and use it in your own circuit. This diagram maps legs of the chip to pins of the Arduino: Arduino - Home

Serial functionality is built into the hardware of the ATmega8 chip. What you will lose is the conversion from TTL serial (e.g. 0 and 5 volt serial, like the ATmega8 outputs) to either USB (which happens via the FTDI chip on the Arduino board) or to standard RS-232 serial (which operates at plus and minus 6 to 15 volts; 12 is common, I believe). If you need, however, to talk to another chip over serial, the built-in TTL serial may be exactly what you need. Or, you can include components in your circuit for conversion to USB or RS-232 serial.

Other things you'll lose (or need to supply yourself) include: power regulator (to go from the supplied voltage to the 5 volts needed for the board), a 16 MHz clock (without a clock, the ATmega8 can only operate at 8 MHz, and you'll need to change its fuses with a hardware programmer to tell it to do so), the reset button, power LED, etc. But really, there's not too much on the Arduino board, so you'll keep most of the functionality. Whatever LCDs you can drive from the Arduino board you'll be able to drive from a standalone ATmega8.

You can indeed take the chip out of the board and use it in your own circuit. This diagram maps legs of the chip to pins of the Arduino: Arduino - Home

Serial functionality is built into the hardware of the ATmega8 chip. What you will lose is the conversion from TTL serial (e.g. 0 and 5 volt serial, like the ATmega8 outputs) to either USB (which happens via the FTDI chip on the Arduino board) or to standard RS-232 serial (which operates at plus and minus 6 to 15 volts; 12 is common, I believe). If you need, however, to talk to another chip over serial, the built-in TTL serial may be exactly what you need. Or, you can include components in your circuit for conversion to USB or RS-232 serial.

Other things you'll lose (or need to supply yourself) include: power regulator (to go from the supplied voltage to the 5 volts needed for the board), a 16 MHz clock (without a clock, the ATmega8 can only operate at 8 MHz, and you'll need to change its fuses with a hardware programmer to tell it to do so), the reset button, power LED, etc. But really, there's not too much on the Arduino board, so you'll keep most of the functionality. Whatever LCDs you can drive from the Arduino board you'll be able to drive from a standalone ATmega8.

Excellent, thanks very much for the very helpful reply - I'm ordering a board from sparkfun today.

On the topic of clocks: if I am using the chip on it's own and omit a clock from my circuit causing the chip to run at half speed, will this cause my timing instructions to take twice as long? So, for instance, if I say delayMilliseconds(1000), will it actually delay for 2000? I guess what I'm trying to ask is: are there functions that are tied to the clock speed, or does the chip have an actual clock in it? Again, sorry for the newbie questions.

The ATmega8 in the Arduino gets configured by us (through internal hardware fuses) for an external clock, meaning that it will not run as-is without a clock. If you want to use it without a clock, you will need to reprogram the hardware fuses with an external programmer (like an AVR-ISP or a homemade parallel programmer: http://www.arduino.cc/en/Main/ParallelProgrammer). If you don't have an external programmer handy, it may be easier to just put a 16 MHz clock and associated capacitors in your circuit (see, for example, this schematic for details: http://www.potemkin.org/uploads/Pid/arduino_usb.jpg). If you do want to reprogram the fuses, let us know and we can help you figure out what the correct fuse settings are and how to set them.

The ATmega8 in the Arduino gets configured by us (through internal hardware fuses) for an external clock, meaning that it will not run as-is without a clock. If you want to use it without a clock, [...]

I see. Sounds like I'll just be including 25 cents worth of extra components :wink:

Thanks again!

I would like to reprogram the fuses to run the ATmega8 on it's own without an external clock. Can you tell me the correct fuse settings ?
Thanks

It depends what speed you want. For 8 MHz (the fastest) you want:

High fuse byte: 0xca (the Arduino default for the ATmega8)
Low fuse byte: 0xd4 (low four bits changed to internal 8 MHz clock)

Note that the bootloader that's on the Arduino board thinks it's running on with a 16 MHz clock. If you change the fuses to run at 8 MHz without compiling and burning a new bootloader, the bootloader will run half as fast as it thinks it is, meaning it will communicate at 9600 baud instead of 19200. So you'll need to change the serial.download_rate in the Arduino preferences file to 9600. You should also change the build.f_cpu from 16000000L to 8000000L so your sketches will run at the correct speed. A few things (like delay microseconds and the analog input routines) may assume a 16 MHz clock and not work quite right. Please let us know if you find such problems, so we can fix them.

For some reason I can not get the ATmega8 to run off the board. I was able to bootload with the suggested fuse settings. I know it worked because the upload is slower now. The blink program works while the processor is on the board but nothing happens off the board. I wired just as indicated with a 5v regulator for VCC. I double checked 10 times. Still nothing. Any ideas ? Has anyone been able to do it ?

Did you pull the reset pin (pin 1 of the ATmega8, not digital pin 1 on the Arduino board) high?

Yes. Pin 1 is high thru 10K Resistor. Has to be pin 1 on ATmega8 not the board. It is off the board.
I believe I have wired it correctly.

Hmm, you might try tying the RX pin (pin 2 of the ATmega8) high. If it's disconnected, it's possible the bootloader receives random serial data which prevents it from timing out and starting your sketch.

Nope. Tried that. I don't even get the LED on Pin 13 blink to indicate the bootloader is running.

Can you take a picture of your setup?

Yes. Look here -> http://home.earthlink.net/~sambenn/

Thanks. Here's a silly question: do you need to connect the two halves of your + and - minus rails?

No. I am only using one set of rails. The AVcc and GND are supplied from the same rail as vcc and gnd. No other connections on that side. Plus I tested current on every pin that should have current and we are good.

Sorry, I meant the two halves of the single + and - rails. Often, there a break halfway along the rail, even though it doesn't look like it. Is that not the case with your breadboard? Or are you bridging the gap in a way I'm not seeing?

I think so too. The (+) and (-) rails are usually broken in the middle in these kind of breadboards. The right half of your breadboard isn't connected to (+).

The rails are broken in the middle. The top rails are not being used at all. I am using the bottom rails to power the chip. The unregulated + power comes in at the right side and is wired to the 5V Regulator. From the regulator the 5V + is wired to the bottom + rail. The bottom + rail is then wired to 10K Resistor to pin 1 and pin2. Then to pin 7 and pin 20 (for avcc). For Negative - the rail is wired to the power source. And to pin 8 and pin 22. Notice the power led I added on the left. It is lit. I'm sorry but grateful that you are taking so much time to help me. I am skeptical of the fuse settings. Has anyone successfully run the ATmega8 off the board?

Maybe you're right about the fuses. Reviewing the data sheet, I see this: "The CKOPT Fuse should always be unpro-
grammed when using this clock option" though no explanation is given. Try these fuses:

High fuse byte: 0xda (CKOPT fuse set to unprogrammed = 1)
Low fuse byte: 0xd4 (low four bits changed to internal 8 MHz clock)