Arduino from Scratch

About the project

…neki uvod
http://wiki.razmjenavjestina.org/index.php/AVR/Arduino_from_the_Scratch

Parts list

??možda staviti napomene ako ima nekih djelova koji su kritični (tipa one diode)??

1x ATMEGA8 16PU-DIP28
1x protoboard, breadboard
2x resistor 68 ohm 
3x resistor 1k
1x resistor 2.2k
2x zener diode 3.6V (0.25W or even less)
1x crystal quartz oscillator 16MHz
1x tantalum capacitor 4.7uF/6V
1x pushbutton
1x LED hi-efficiency red 5mm
1x LED hi-efficiency green 5mm
1x LED hi-efficiency blue  5mm

Assembly and Schematic


arduino-scratch-06.png
arduino-scratch-atmega8-11.pdf

Loading USBasp bootloader on ATMEGA

Start from
http://www.obdev.at/products/vusb/usbasploader.html
Edit bootloaderconfig.h and
adapt port names according to schematic and
Quartz frequency used and
Use ISP programmer like stk500 compatible
http://wiki.ullihome.de/wiki/USBAVRLab/Firmwares/SK500v2
or another hardware USBasp to burn the bootloader
into atmega8, take care to burn correct fuses and lock bits
for atmega8

USBasp driver installation

Linux and MacOS X

No driver is needed.

Windows XP

1. Download and unzip USBasp driver
http://www.fischl.de/usbasp/usbasp-windriver.2011-05-28.zip
2. Plug-in Arduino and click reset button.
3. New hardware will be found, update driver by pointing it to the USBasp driver directory

Windows 7

Follow the instructions from the link below. We found that this solution doesn't work on all Win 7 computers. Also note that device will only work on usb port used during installation ???CHECK???. Plug-in the Arduino and click reset button before creating driver.
http://www.wortelsoft.nl/english/usbasp.html

Programming with AVRDUDE ??? ili šta ???

Linux

MacOS X

Install CrossPack. CrossPack is a development environment for Atmel’s AVR® microcontrollers running on Apple’s Mac OS X, similar to AVR Studio on Windows. It consists of the GNU compiler suite, a C library for the AVR, the AVRDUDE uploader and several other useful tools.
http://www.obdev.at/products/crosspack/index.html

Windows

Programming with Arduino IDE

1. Download latest Arduino software for your OS:
http://arduino.cc/hu/Main/Software

2. Find file "boards.txt" inside Arduino app folder, and add following lines at the bottom.

##############################################################

scratch.name=Arduino from Scratch w/ ATmega8

scratch.upload.protocol=usbasp
scratch.upload.maximum_size=6144
scratch.upload.speed=19200

scratch.bootloader.low_fuses=0xdf
scratch.bootloader.high_fuses=0xca
scratch.bootloader.path=atmega8
scratch.bootloader.file=ATmegaBOOT.hex
scratch.bootloader.unlock_bits=0x3F
scratch.bootloader.lock_bits=0x0F

scratch.build.mcu=atmega8
scratch.build.f_cpu=16000000L
scratch.build.core=arduino

3. Open Arduino IDE. Go to Tools menu and set Programmer to "USBasp" and Board to "Arduino from Scratch w/ ATmega8"
4. Click reset button on Arduino.
5. Paste "timer.c" code in new file and click "Upload". Ignore the warning "avrdude: warning: cannot set sck period. please check for usbasp firmware update.". Arduino should start blinking immediately – you have just reprogrammed it :-)

Next you can try some Arduino examples. Note that Arduino IDE uses it's own nomenclature for the ports (digital 1,2,3… analog in 1,2,3…). Trace them on Arduino schematic to find to which ATmega8 chip pin they are mapped. You can also use diagram below, or print out small sticker and stick it over ATmega8 chip.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License