Go Down

Topic: Can I use the ATMega8 on it's own? (Read 5080 times) previous topic - next topic

rotor

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!

mellis

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: http://www.arduino.cc/en/Main/PinMapping

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.

rotor

Quote
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: http://www.arduino.cc/en/Main/PinMapping

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.

mellis

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.

rotor

Quote
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 ;)

Thanks again!

Sambb

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

mellis

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.

Sambb

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 ?  

mellis

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

Sambb

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.

mellis

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.

Sambb

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

mellis

Can you take a picture of your setup?  

Sambb

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

mellis

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

Go Up