Sunday, April 11, 2010

AVR - Nasty thing

Last month, I had a project that need one ‘big’ button that can interact with my computer software. There shouldn’t be a problem if I bought a decent programmer for AVR. But I like to make it from the lowest level: the beginning. First, I had to choose what kind of MCU (micro controller) I should use. From what I needed, Attiny2313 or Attiny45 from Atmel was good enough. And then all the problems began…

I made some ISP cables, but they didn’t work. So I had to build better programmer. AVR910-USB is a good one, The circuit is simple. Unfortunately, it need a programmer to upload the firmware to AVR910-USB’s heart - ATMEGA8. This is the “chicken and egg” problem. So, I had to borrow a programmer from my friend, which also is AVR910 USB, to upload the code to my AVR910 programmer.

I found some layouts, but I didn’t like them, so I designed one for my self. I needed to work with Tiny45 and Tiny2313, so I add ZIF20 pin and crystals, voltage regulator. I learned that the chip need stable voltage when programming. I killed 1 tiny45 by powered it with 7 volt (from a 5v adapter, how the heck it could be with a switching power supply) and 4 tiny2313, 2 mega8 by wrong fuse.

After trials, I success to make a programmer.

Here are some pictures

AVR910copper.png
AVR910top.png
AVR910_USB.jpg

I also made a develop board for ATTINY2313:

TINY_DEV_BOARD.jpg

Since I chose AVR, I had to deal with fuse bits. I made some mistakes and burnt out some chips. I’ll have to be more careful. There are something that I took note:

- Don’t mess with fuse bits.
- Don’t program fuse bits many times.
- AvrProg program the chip very fast.
- Don’t rely on AvrProg to program fuse (even it is looked pretty simple and clear).
- Don’t program the chip without a stable 5v.
- Use CodeVision to program the fuse.
- Do research Fuse Calculator before program fuse.
- Bit 0 = programmed (checked), bit 1 = un-programmed (unchecked).
- If wrong fuse programmed, you will need High Voltage Programmer
- After about 10 times or so, Tiny2313 won’t allow programming via ISP cable anymore. I think I can do a HVPP fuse reset, but still I can’t program the chip via ISP (4 tiny2313 had been killed when I’d been developing and testing firmware). I may work with HVPP. (Maybe it’s bad quality chips)

All files for this entry:
- AVR 910 note from Atmel
- Schema + Images
- Layout for SprintLayout
- Sample code
[attach=dow/avr910usb.rar]Download[/attach]

—————————————————
Here are good places to visit:
‘First contact with ATmega8′ by Denilson Figueiredo de Sá
Fuse Calculator
denki.world3.net - I don’t know what to describe this site
USBasp programmer hompage
A Beginners Guide to Programming the ATMEL ATtiny 45 and 85

[tag]AVR 910[/tag]