This is an old revision of the document!
The following guide describes the AVR development environment setup, if not used HomeLab precompiled installing package.
It is necessary to install the following software bundle:
1. CodeBlocks CodeBlocks IDE (Integrated Development Environment), for software writing and its loading into the microcontroller.
2. ATMEL AVR Toolchain
AVR Toolchain is GNU-GCC compiler for AVR microcontrollers. This is a freeware which can be found on Atmel's website.
3. HomeLab library
HomeLab library contains a various functsions to make AVR and HomeLab kit programming simpler. The last versions for this library can be found on HomeLab website.
4. DFU-Programmer
DFU-Programmer is for programming HomeLab III series controller and using its bootloader
Following guide describes HomeLab III (Controller v1 - ATxmega128A1U) development enviroment setup and use in Windows operating system.
First install CodeBlocks software.
No need to install CodeBlocks plugis.
Next choose correct location for CodeBlocks. All examples are in default location C:\HomelabCB
Then CodeBlocks software install on the computers.
When CodeBlocks are installed, then add: AVR Toolchain, HomeLab library, DFU-Programmer
First of all, you should choose the folder where you installed the CodeBlocks, because of all the extras installed in the same folder.
The first launch prompted compiler location. May be select *No Compiler*, because the choice of the compiler is set manually at a later, and it is dependent to the project template.
Then, the compiler should be set. Enter the menu Settings → Compiler…. In the opened window should be set to the following lines:
Observe that would be selected GNU GCC Compiler for AVR and show where to install the software. If the installed sowtware location is not C:\HomelabCB then should be made corresponding changes themselves.
Then configure the programmer to be able to download the code directly from CodeBlocks environment. In order to find the menu Tools → Configure tools… and choose Add. In the opened windows write the following rows dependent HomeLabs generation:
HomeLab III
HomeLab II (Atmega2561)
Paigaldada Codeblocks lisad:
sudo apt-get install codeblocks-contrib
dfu-programmer-i tavakasutaja õigustes käivitamiseks on vaja luua udev reeglite fail Genereerida ruled.d kataloogi fail sisuga:
SUBSYSTEM=="usb",ACTION=="add",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="*",GROUP="plugdev"
Samuti on vaja paigaldada teek. Tüüpiliselt asuvad avr-i teegid kausta /usr/lib/avr Sinna kausta uute teekide lisamiseks on vaja administraatori õigusi.
Juhul kui AVR Toolchain ei ole repositooriumites veel uuendatud, siis võib ADC funktsioon anda veateate. Selle ellimineerimiseks võib käsitsi asendada avr kaustas oleva iox128a1u.h faili (sisaldub teegis).
Programmeerimise lihtsustamiseks võib luua järgmise batch faili:
sudo nano /usr/bin/homelab-programmer
faili sisuks kopeerida:
#!/bin/bash dfu-programmer atxmega128a1u erase dfu-programmer atxmega128a1u flash $1 dfu-programmer atxmega128a1u start
loodud failile anda käivitamise õigused:
sudo chmod 775 /usr/bin/homelab-programmer
Codeblocks Tools→Configure tools …
Seadistada programmaator järgmiselt.
Projekti loomine käib menüüst File→New→Project. Sealt tuleks valida vastavalt Kodulabori versioonile projekt ning konfigureerida see vastavalt soovile.
Kõigepealt valida projektile nimi ning asukoht. Vältida täpitähtede kasutamist.
Seejärel valida projekti kompileerimiskaust. Soovitatav jätta selleks, mis on.
Seejärel valida mikrokontroller ning kasutatav taktsagedus.
Viimaseks tuleks määrata ära AVR Toolchaini installatsioonikataloog.
Kui projekt on loodud, ilmub vasakule projektipuusse uus projekt koos näitekoodiga. Kompileerimine käib CodeBlocksis ülal real olevate hammasratta ikoonidega. Kui kompilatsioon õnnestub kuvatakse all Build Log aknas kasutatud programmimälu maht ning ebaõnnestumise korral errorid.
Programmi peale laadimiseks, tuleb Kodulabor III kontrolleril käivitada buudilaadur hoides all S0 nuppu ja tehes kontrollerile reset. Varasemate Kodulaboritega seda teha vaja ei ole. Kui vajalikud draiverid on paigaldatud (Draiverid asuvad CodeBlocks/Programmer kaustas), siis saab kompileeritud hex faili peale laadida. Selleks tuleb käivitada programmaator menüüst Tools.