| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| en:examples:setup:windows:eclipse_v5 [2012/05/28 08:38] – eero.valjaots | en:examples:setup:windows:eclipse_v5 [2020/07/20 09:00] (current) – created - external edit 127.0.0.1 |
|---|
| ====== Development environment Eclipse (Windows) ATmega2561 ====== | ====== Development environment Eclipse (Windows) ATmega2561 ====== |
| |
| This section contains the information necessary to install HomeLab ver. 5 (Microcontroller v1 - ATmega2561) development software and initial setup on Windows operating system. | This section contains the information necessary to install HomeLab version 5 (Microcontroller v1 - ATmega2561) development software and initial setup on Windows operating system. |
| |
| ===== Installation ===== | ===== Installation ===== |
| The following steps have to be completed when creating new project with the help of wizard: | The following steps have to be completed when creating new project with the help of wizard: |
| |
| **1.** Start Eclipse (Robotic HomeLab IDE) and ja setup new project. Kui Tarkvara on äsja paigaldatud, on esmalt vaja tekitade projektide repositoorium ehk //Workspace//. Selleks näidake avanenud aknas //Workbench// asukoht, kuhu soovite projektide repositooriumi luua. | **1.** Start Eclipse (Robotic HomeLab IDE) and ja setup new project. If the software is newly installed, project repository //Workspace// must be created. To do this, select the //Workspace// folder location in main window where the repository will be created. |
| |
| {{:software:eclipse:eclipse0.jpg?520|}} | {{:software:eclipse:eclipse0.jpg?520|}} |
| {{:software:eclipse:eclipse1.jpg?500|}} | {{:software:eclipse:eclipse1.jpg?500|}} |
| |
| Uue projekti loomiseks tuleb valida menüüst //File - New - C project//. Lisada projekti nimi ning vajutada nupule //Next//. | To create the new project, select in menu //File - New - C project//. Add project name and click //Next//. |
| |
| **2.** Järgmises aknas tuleks projekti konfiguratsiooniks valida ainult Release | **2.** Project configuration in the next dialog box should be selected as only Release. |
| |
| {{:software:eclipse:eclipse3.jpg?400|}} | {{:software:eclipse:eclipse3.jpg?400|}} |
| |
| **3.** Järgnevalt avaneb aken, kus tuleb märkida mikrokontrolleri tüüp ja taktsagedus. Kodulabori (v5) mikrokontrolleriks on //ATmega2561// ja taktsageduseks 14745600 Hz. Projekti lõplikuks loomiseks vajutada nupule //Finish//. | **3.** In the next window, microcontroller type and working frequency must be selected. Robotic HomeLab (v5) microcontroller is //ATmega2561// working frequency 14745600 Hz. To finish project setup click //Finish//. |
| |
| {{:software:eclipse:eclipse4.jpg?400|}} | {{:software:eclipse:eclipse4.jpg?400|}} |
| |
| **4.** Nüüd avaneb juba programmeerimise kasutajaliides, kuid enne, kui saab hakata programmi kirjutama, on vaja tekitada algkoodi fail. Selleks valige äsjaloodud projektil hiire parema klahviga //New - Source File// ja sisestage soovitud faili nimi, mis peab kindlasti lõppema laiendiga ".c". Soovitav on peafaili nimeks valida "main.c". Peale //Finish// nupu vajutamist luuakse vastav fail ja avatakse see arenduskeskkonda. | **4.** After this the user interface for program development will open. Before you can start writing code, new file for source code is needed to create. To do this, click mouse right button on your fresh project, select //New - Source File// and input a name to it, which must be ended with ".c". It is recommended to name the main file as "main.c". After pressing //Finish// button, a new file is created and opened in development environment. |
| |
| {{:software:eclipse:eclipse5.jpg?400|}} | {{:software:eclipse:eclipse5.jpg?400|}} |
| |
| **5.** | **5.** |
| Enne lähtekoodi kirjutamist on mõistlik teha mõned seadistused, mis peaks hõlbustama arenduskeskkonna kasutamist. | Before you start writing the source code, it is advisable to make some changes in preferences for easier use of development environment. |
| Valige menüüst //Window - Preferences// ja avage vasakul olevast puust //General - Workspace// ning märkiga ära valik //Save automatically before build// | Choose from menu //Window - Preferences// and navigate from leftside tree to //General - Workspace// and select option //Save automatically before build// |
| |
| {{:software:eclipse:eclipse6.jpg?400|}} | {{:software:eclipse:eclipse6.jpg?400|}} |
| |
| **6.** Edasi võib hakatuseks kopeerida alloleva testprogrammi lähtekoodi ja üritada seda kompileerida. Kompileerimiseks võib kasutada klahvikombinatsiooni CTRL+B. | **6.** For testing the correct operation of Eclipse, the following source code can copied to environment and compiled. For compilation the keyboard combination of CTRL + B can be used. |
| |
| <code c> | <code c> |
| //Lihtne testprogramm, mis ei kasuta Kodulabori teeki. | //A simple test code which is not using HomeLab library |
| #include <avr/io.h> | #include <avr/io.h> |
| | |
| { | { |
| unsigned int x,y; | unsigned int x,y; |
| // Viigu PB7 seadmine väljundiks | // Set pin PB7 as output |
| DDRB = 0x80; | DDRB = 0x80; |
| | |
| // Lõputu tsükkel | // Infinite loop |
| while (1) | while (1) |
| { | { |
| // Viigu PB7 inverteerimine | // Invert pin PB7 |
| PORTB ^= 0x80; | PORTB ^= 0x80; |
| y=3200; | y=3200; |
| </code> | </code> |
| |
| Kompileerumise õnnestumiseks peab olema tarvarakood ilma vigadeta ja kompilaator peab leidma kõik vajalikud päisfailid. Eduka kompileerumise tunnuseks on //Problem// aknas tühjus (äärmisel juhul mõni hoiatus //Warning//) ja //Console// aknas kompilaatori väljund mis antud projekti puhul on midagi sellist: | For successful compilation, the code is needed to be error free and the compilator must be able to find all necessary header files. A successful compilation is indicated in //Problem// window as emptiness (or at outermost cases some warnings //Warning//) and in //Console// window as the output of compilator which will for example be in this case: |
| |
| AVR Memory Usage | AVR Memory Usage |
| {{:software:eclipse:eclipse7.jpg?520|}} | {{:software:eclipse:eclipse7.jpg?520|}} |
| |
| Kui koodis oli viga või ei leitud päisfaile, siis on //Console// aknas viimasel real veateade koos leitud vigade arvuga, millele eelneb leitud võimaliku vea kirjeldus. | If the code has errors or header files are not found, then the //Console// window displays the number of errors on end line and describes possible faults above it. |
| |
| ../main.c: In function 'main': | ../main.c: In function 'main': |
| make: *** [main.o] Error 1 | make: *** [main.o] Error 1 |
| |
| Samuti on //Problems// aknas erinevad veateated ja vastav koht koodis märgitakse vea ikooniga. | Alsothe //Problems// window displays several error messages and corresponding location in code is marked with error icon. |
| |
| {{:software:eclipse:eclipse8.jpg?520|}} | {{:software:eclipse:eclipse8.jpg?520|}} |
| |
| **7.** Kodulabori teegi kasutamine eeldab, et see on tarkvara paigaldamise juhendi kohaselt süsteemi paigaldatud. Iga projekti korral tuleb teek projekti seadetest lisada lingitavate objektide nimekirja. Selleks avada esmalt: //Project -> Properties// ja seejärel vasakust puust //C/C++ Build -> Settings//, edasi //Tool Settings -> AVR C linker -> Libraries//. Paremal avanenud aknas valida //Libraries (-l)// osas ikoon //Add...// ja sisestada avanenud aknasse homelab2561. Seejärel //OK// ja veelkord //OK//. | **7.** For using HomeLab library, it is assumed to be correctly installed into operation system with the help of instruction. For every project the library must be included into list of linkable objects in project options. To do this, open at first: //Project -> Properties// and then from leftside tree //C/C++ Build -> Settings//, further //Tool Settings -> AVR C linker -> Libraries//. Choose in window that opened in the right under //Libraries (-l)// icon //Add...// and input to the dialog box "homelab2561". Then //OK// and one more //OK//. |
| |
| {{:software:eclipse:eclipse10.jpg?520|}} | {{:software:eclipse:eclipse10.jpg?520|}} |
| |
| **8.** Edasi võib teegi testimiseks kopeerida alloleva testprogrammi lähtekoodi eelmise asemele ja üritada seda kompileerida. Kompileerimiseks võib kasutada klahvikombinatsiooni CTRL+B. | **8.** For testing HomeLab library the following source code can be used when copied besids the previous code and compiled. You can again use CTRL + B combination on keyboard. |
| <code c> | <code c> |
| //Lihtne testprogramm, mis kasutab Kodulabori teeki. | //A simple test code which uses HomeLab library |
| #include <avr/io.h> | #include <avr/io.h> |
| #include <homelab/delay.h> | #include <homelab/delay.h> |
| int main(void) | int main(void) |
| { | { |
| // Viigu PB7 seadmine väljundiks | // Set pin PB7 as output |
| DDRB = 0x80; | DDRB = 0x80; |
| |
| // Lõputu tsükkel | // Infinite loop |
| while (true) | while (true) |
| { | { |
| // Viigu PB7 inverteerimine | // Invert pin PB7 |
| PORTB ^= 0x80; | PORTB ^= 0x80; |
| hw_delay_ms(500); | hw_delay_ms(500); |
| </code> | </code> |
| |
| Kui ka selle koodi kompileerimine õnnestub, siis on kõik eelnevad seadistused tehtud õigesti. | If compilation of this code is also successful, the development environment was set up correctly. |
| |
| ~~PB~~ | <pagebreak> |
| |
| ===== Kontrollerile koodi laadimine ===== | ===== Loading the code into microcontroller ===== |
| |
| **1.** Ühendada kontrollerplaat USB kaabliga arvutiga. Peale kontrollerplaadi ühendamist peaks (esmasel ühendamisel teatud aja pärast) süttima väike roheline toite LED - PWR. | **1.** Connect the microcontroller board to PC using USB cable. After successful connection a small green LED labeled as PWR will light up (after some time on first connection). |
| |
| **2.** Määrata programmi laaduri (AVRDude) seaded. Selleks avada uuesti projekti seaded //Project -> Properties// ja seejärel vasakust puust //AVR -> AVRDude//, edasi //Programmer configuration -> New//. Avanenud aknas midagi eriti seadistada pole vaja ja võib kohe //OK// vajutada. Veenduge et see oleks valitud ja vajutage //Apply// ning //OK//. | **2.** Set options for program loader (AVRDude). For this again open project properties //Project -> Properties// and from leftside tree //AVR -> AVRDude//, further //Programmer configuration -> New//. The dialog box that now opens needs no changes and you can press //OK// button. If it is selected press //Apply// and then //OK//. |
| |
| {{:software:eclipse:eclipse9.jpg?520|}} | {{:software:eclipse:eclipse9.jpg?520|}} |
| |
| Oluline on kontrollida, et nüüd oleks //Programmer configuration// valikus midagi valida ja juhul kui eelnevalt midagi ei muudetud on selleks: //New Configuration//. | It is important to check that in list //Programmer configuration// something can be choosed and by default this will be: //New Configuration//. |
| |
| {{:software:eclipse:eclipse11.jpg?520|}} | {{:software:eclipse:eclipse11.jpg?520|}} |
| |
| |
| **3.** Kui Kodulabori Kontrollermoodul on arvutiga ühendatud võib kompileeritud programmi nüüd üritada laadida kontrollerisse. Selleks vajutage lihtsalt AVR ikoonile või klahvikombinatsioon CTRL + Alt + U. | **3.** If HomeLab microcontroller module is connected with PC, you can now try to load the compiled program into microcontroller. For this simply press AVR icon or use CTRL + ALT + U in keyboard. |
| | |
| Programmi mõjul peaks kontrolleri plaadil olev oleku-LED PB7 perioodiliselt süttima ja kustuma. Kui programm töötab, on tarkvara paigaldatud edukalt ja esimene projekt tehtud. Palju õnne! | As an effect of this program, the on-board LED (PB7) should start flashing. If the program works, you have successfully set up your programming environment and completed your first program. Congratulations! |
| |
| {{:kit:kit_2561_test.jpg?400|}} | {{:kit:kit_2561_test.jpg?400|}} |
| | |
| | ===== Using floating-point variables ===== |
| | |
| | It is sometimes necessary in AVR programs to use floating-point variables. For calculating with them and presenting with //printf//-type functions, the following changes are necessary in the configuration of the project: |
| | |
| | **1.** Open the configuration of the project from the menu //File → Properties//. On the leftside panel open //AVR C Linker → Libraries//, where in addition to HomeLab library other library objects must be included //printf_flt// and //m// (libprintf_flt.a ja libm.a). |
| | |
| | **2.** Then open //AVR C Linker → General// and into box of //Other Arguments// add line //-uvfprintf//. |
| | |
| | {{:examples:eclipse:eclipse_floating_point_libraries.png?520|}} |
| | |
| | {{:examples:eclipse:eclipse_floating_point_printf.png?520|}} |
| | |
| | **3.** Press OK and close configuration window. |