Programmers

All on one SLOW page
Serial Port
Parallel Port
Smart Programmers
Serial Loaders

Projects

ATmega8 Serial LCD
ATtiny2313 Serial LCD
ATtiny4313 Serial LCD
ATmega328 SIRC
ATtiny2313 SIRC
40-pin Dev Board
28-pin Dev Board
AVR PS/2 Keyboard
AVR MAX232 RTS/CTS
AVR Dual RS232 Ports

Minimal Circuits

ATmega16
ATmega32
ATmega644
ATmega1284
ATmega8515
ATmega8535
ATmega8
ATmega48
ATmega88
ATmega168
ATmega328
ATmega162
ATmega128
ATtiny13
ATtiny2313
ATtiny4313
ATtiny24
ATtiny84
ATtiny25
ATtiny45
ATtiny85

Other Stuff

ATtiny13 vs ATtiny85
ATmega8 vs ATmega88
ATmega16 vs ATmega164
ISP and SPI
MAX232 Arduino
A small FAQ
Hardware Info

AVRProgrammers.com AVR FAQs

Why is my programmer intermittent?

If your cable is too long, ringing will stop it from working right. If the cable is shorter, it may work all of the time. If you are like me, and you make the cable from the programmer to the AVR just the right size, the ringing will sometimes stop the programmer from working, and sometimes not. For instance, my favorite AVR programmer works on every test board I have. When I built the ATmega128 board I had to mount the ISP connector on a carrier board, then run the wires to the SchmartBoard that held the MCU. That additional 1 or 2 inch length was enough to make the programmer intermittent. It would literally fail once and then work once. The only line that cares about transitions is the SCK line. Ringing on that line can make the AVR think it is getting two or more clock transitions instead of one. The design calls for 330 Ohm resistors in series with each lead, to cut down on ringing. I added an 11pF capacitor to ground on the output end of the 330 Ohm resistor, and the thing is 100% reliable with the ATmega128 board. Another board might require a larger capacitor, but don't get carried away. You can delay the clock to the point that it no longer falls in the bit time. The 330 Ohm / 11 pF combination puts a few nanoseconds of delay in the line, but really calms down the ringing.

[Top]
Why can't I drive an LED from the ATmega?
  • Make sure you have the port pin set to output, by writing a "1" to the port's DDR.
  • Make sure you have the LED in the circuit correctly. The flat side is the cathode and is connected to the most negative voltage.
  • You must have a power supply voltage that exceeds the forward voltage on the LED. If you don't know the forward voltage, put a 1k resistor in series with it, hook it to the power supply, and measure the voltage across the LED. If it is equal to the power supply voltage, you don't have a high enough power supply voltage. If it is not, then the voltage you are measuring is the forward voltage of the LED. Here is an excellent reference on LEDs.
[Top]
How do I connect a MAX232 to an Arduino?
  • Build a MAX232 circuit using any of the hundreds of designs (here's a MAX232 hooked to an ATmega)
  • Hook it to your Arduino, or any other microcontroller, like this:
    • The MAX232 RXDOUT line goes to the AVR RX pin, or Arduino Digital pin 0
    • The MAX232 TXDIN line goes to the AVR TX pin, or Arduino Digital pin 1
    • Hook ground to any available ground
[Top]
How do I connect an FTDI USB to TTL cable to an AVR for communication to the PC?
  • It is the same pinout as seen on the Arduino Pro board or the USB bootloader circuit.
  • Hook it to your ATmega like this:
    • The FTDI TX line goes to the AVR RX pin, or Arduino Digital pin 0
    • The FTDI RX line goes to the AVR TX pin, or Arduino Digital pin 1
    • Hook one ground to any available ground
    • The other signals are not needed
[Top]
Does the AVR use more or less current with a floating input?

From the Atmel site:
"One of the most important considerations is to ensure a defined level on all I/O pins. A floating pin will give a significant increase in the overall power consumption."

  • Disable pullups on unused pins, and set them to output. With the pullup disabled, there will be very little current draw.
  • Always disable digital inputs on pins used for analog input. This is a major consumer of power.
[Top]
What kind of battery should I use for my portable project?

There are hundreds of answers. Here are a few.

  • If you want to use "standard" batteries:
    • Rechargeable batteries are typically 1.2VDC, remain there for most of their discharge cycle, then drop to nearly zero, while alkaline batteries have a linear voltage drop during discharge. You cannot count on them to put out a constant voltage, although the voltage starts out higher at 1.5VDC.
    • Ni-MH batteries don't "learn" a discharge rate like NiCd, but they can't be recharged as many times.
    • Ni-MH batteries are not as toxic as some of the alternatives.
  • If you're Ok using exotic (ie. expensive) batteries:
    • Standard lithium batteries put out around around 1.75V.
    • The Energizer Bunny sells two types of lithium batteries in AA size that should be the best bang for the buck.
    • Tadiran makes a Lithium Organic AA battery that can put out 5A continuous and has a voltage of 4VDC. It costs a bit over $25.00 and is only 550mAH.
    • Lithium Ion batteries have a 3.6VDC cell voltage, are rechargeable, but require great care in charging and discharging. So much so that the batteries typically have charge and discharge limiters in them to prevent the buildup of lithium metal. Unfortunately they age very quickly, and may not last more than three or four years, even if they are not used.
    • Lithium batteries are toxic.
    • Lithium Ion batteries are not so toxic.

A very good, although slightly biased source of information is found on Michael Bluejay's battery page. You should check out the rest of the site, too. A source for batteries, if you can't find Radio Shack, is Batteries and Butter.

My own preference would be to stick to the batteries I can get at the Radio Shack when I need them in a hurry. And Ni-MH are both the best value for rechargeable, and the best for use without a voltage regulator. And you still need power supply and AREF bypass capacitors. Four cells get you around 4.8VDC, three will provide 3.6VDC. I've seen three cell holders at Mouser.

[Top]
Can I use a regulated wall wart power supply?

Hmm... I really like using the CUI V-Infinity EPS series power supply. They are around $8.00 at Digikey. I have many of them. All but one are EPS12050 12VDC @ 0.5A. The odd one is an EPS050100, 5VDC @ 1.0A. I wired up a board with a bunch of circuitry, several microcontrollers, and hooked it all up to use the 5V supply. I'm always plugging and unplugging things, so of course on one occasion I unplugged the 5V supply, but plugged in the 12V supply. It took me longer to realize why the LEDs were so bright than it did to cook 3 microcontrollers. I normally always put the power supply on the board first - the proper capacitors, a single blocking diode, and a 5V regulator. It costs about $2.00, and I can use one of the EPS 12V supplies with it. Every so often I like to take a refresher course in basic electronics like this. And it only cost me $20.00 for the first lesson. The problem is I keep taking the first lesson over and over.

So. The answer is yes. You can use a regulated wall wart directly, but either get rid of all of your 12VDC warts, or keep spare microcontrollers on hand. They are part of the supplies you'll need for your basic electronics class.

[Top]
Does the AVR use less current in the reset state?

This question has come up a couple of times. I checked it out because it peaked my curiosity.

Yes. The ATtiny2313 SIRC project board uses 10.98mA when it is running, and only 6.31mA when it is held in reset (I soldered a wire between reset and ground). I have no reset pullup on the board - it uses the internal pullup - but it would in the real world, too, so the measurement is valid. Remember this is the total current required for the board, and there is a TFMS5400 in there with a normally high output connected to a high impedance input. The same high impedance the input presents during reset. The TFMS5400 is not affected by the state of the reset signal. What I was not equiped to determine was what, if anything, does having an analog input active do to the power consumption during reset. The inputs are put into a tri-state mode, but the tri-state mode is a digital input with no pullup. Exactly the mode that is described as bad in the AVR FAQ on the Atmel site for use on analog inputs. There is a DIDR to disable digital inputs, but during reset, it is set to enabled.

The question that comes to mind for me is "What do you do with an AVR that is held in reset?". I'm sure there are reasonable answers, but I would guess they are edge cases.

[Top]
How can I use the ATmega128? It is in a TQFP package.

This question is mine.

Three ways:

  • Design your own circuit board for the project. This can be expensive if you are not passing the cost along to a customer. You will have to hold and solder the 64-pin 0.8mm pitch device by hand.
  • Use a header board from Sparkfun Electronics. Less than $4.00. You will have to hold and solder the 64-pin 0.8mm pitch device by hand.
  • If you drink as much coffee as I do, get a SchmartBoard. They literally take five minutes to solder. No components mount on the board, other than the microcontroller. The board nearly grabs the part. $10.00 at Fry's Electronics, or anywhere.

I got both the SchmartBoard and the ATmega128 from Mouser. $10 for the board and $7 for the ATmega. If you go with the Sparkfun breakout board, you've got $10 total invested in the board and ATmega128.

[Top]
I can't get the Baud rate right and timers don't measure correctly.

Regardless of which oscillator type you use, the clock divde by 8 feature can be set. It is by default, and unless you specifically program a fuse, it will always divide by 8. This is one that bites me a lot. Write a bunch of code, burn it, and nothing works right. Oops. Fuses.

[Top]
What are the differences between AVR's?

I have had some fairly basic questions about the different versions of 8-bit AVR's. The short answer is there are about 190 different versions of the AVR, differing almost entirely in the peripheral selection. There are basic differences between the ATtiny and the ATmega:

  • The ATmega has around 131 instructions, while the ATtiny has around 120
  • The ATmega has a hardware multiplier, while the ATtiny does not
  • The ATtiny will operate at 0.7V (wow)
  • The ATtiny's mostly have no USART, but have some "building blocks" to help make a software UART easier
  • The ATtiny's do not have self-programmable flash, so bootloaders are not available

The similarities in the ATmega and ATtiny MCU's can be seen generally in the last digit of the part number. An ATmega324 and an ATmega644 are the same part with different memory sizes. The ATmega324 and ATmega328 are completely different parts. The ATtiny24, 44, and 84 are identical, except for memory sizes. The ATtiny24 and ATtiny25 are different. Exceptions are the ATmega8515 and ATmega8535, which are pinned out like the ATmega162 and ATmegaxx4 (164/324/644/1284) respectively.

[Top]
Can an Arduino program other AVR's?

The ArduinoISP program can be used to program any AVR having a "normal" SPI programming interface.

[Top]
What's the difference between AVR ISP and parallel programming?

AVR ISP programming is done with a low-voltage (5V max nominal) power supply and an SPI interface to the AVR. Most AVR microcontrollers support this interface. Some don't have enough pins, and use a different interface. It is possible to program the fuse bytes in a way that prevents the part from being programmed again. This is done by disabling the reset line, generally by accident, when programming through the SPI interface. If this happens, the part is not reprogrammable. At least not with the SPI interface. There is another interface on most AVR's that is a "high-voltage parallel" interface. The interface is more complicated, since it is parallel, and requires a 12V+ power supply. The AVR can be programmed regardless of the fuse settings, and typically, the only use for the high-voltage parallel interface is to reprogram the fuses. This allows the part to be programmed again using the standard low-voltage SPI interface. Parts that don't have enough pin for SPI certainly don't have enough for the parallel interface, and so they support a high-voltage serial programming interface.

[Top]
Can you use RTS / CTS with an AVR?

Yes. Modem control, such as RTS/CTS handshake, is just a pair of signals - one input and one output - that the DTE and DCE use to control transmission from the DCE (modem) to the DCE (host). For an example schematic, see the AVR RS232 project. It demonstrates connecting a MAX232 to an AVR for TXD, RXD, RTS, and CTS.

[Top]