This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| en:examples:setup:windows:eclipse_v5 [2012/05/29 11:34] – removed raivo.sell | en:examples:setup:windows:eclipse_v5 [2020/07/20 09:00] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Development environment Eclipse (Windows) ATmega2561 ====== | ||
| + | This section contains the information necessary to install HomeLab version 5 (Microcontroller v1 - ATmega2561) development software and initial setup on Windows operating system. | ||
| + | |||
| + | ===== Installation ===== | ||
| + | |||
| + | For installation the HomeLab development software must be downloaded for your operating system. The software package contains Eclipse development environment, | ||
| + | |||
| + | **MS Windows** | ||
| + | |||
| + | Software download -> [[et: | ||
| + | |||
| + | **Linux Ubuntu** | ||
| + | |||
| + | Software download -> [[et: | ||
| + | |||
| + | **Linux other and Mac OS** | ||
| + | |||
| + | The following software is required to be installed: | ||
| + | * Eclipse | ||
| + | * Eclipse AVR plugin | ||
| + | * Hlinit | ||
| + | * Hlflash | ||
| + | * AVRdude mod. | ||
| + | * Robotic HomeLab library | ||
| + | |||
| + | ===== Creating new project ===== | ||
| + | |||
| + | In order to write a program for the controller you need to create the new project. The project includes typically different files like source codes, header files, compiled program files, etc. It is strongly advised to create new folder for every project (which is offered also by the New Project 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. If the software is newly installed, project repository // | ||
| + | |||
| + | {{: | ||
| + | {{: | ||
| + | |||
| + | To create the new project, select in menu //File - New - C project//. Add project name and click //Next//. | ||
| + | |||
| + | **2.** Project configuration in the next dialog box should be selected as only Release. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | **3.** In the next window, microcontroller type and working frequency must be selected. Robotic HomeLab (v5) microcontroller is // | ||
| + | |||
| + | {{: | ||
| + | |||
| + | **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 " | ||
| + | |||
| + | {{: | ||
| + | |||
| + | **5.** | ||
| + | Before you start writing the source code, it is advisable to make some changes in preferences for easier use of development environment. | ||
| + | Choose from menu //Window - Preferences// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | **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> | ||
| + | //A simple test code which is not using HomeLab library | ||
| + | #include < | ||
| + | |||
| + | int main(void) | ||
| + | { | ||
| + | unsigned int x,y; | ||
| + | // Set pin PB7 as output | ||
| + | DDRB = 0x80; | ||
| + | |||
| + | // Infinite loop | ||
| + | while (1) | ||
| + | { | ||
| + | // Invert pin PB7 | ||
| + | PORTB ^= 0x80; | ||
| + | y=3200; | ||
| + | while(y--){ | ||
| + | x=260; | ||
| + | while(x--){ | ||
| + | asm volatile (" | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | For successful compilation, | ||
| + | |||
| + | AVR Memory Usage | ||
| + | ---------------- | ||
| + | Device: atmega2561 | ||
| + | Program: | ||
| + | (.text + .data + .bootloader) | ||
| + | Data: 0 bytes (0.0% Full) | ||
| + | (.data + .bss + .noinit) | ||
| + | Finished building: sizedummy | ||
| + | |||
| + | {{: | ||
| + | |||
| + | 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 ' | ||
| + | ../ | ||
| + | ../ | ||
| + | make: *** [main.o] Error 1 | ||
| + | |||
| + | Alsothe | ||
| + | |||
| + | {{: | ||
| + | |||
| + | **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// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | **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> | ||
| + | //A simple test code which uses HomeLab library | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | int main(void) | ||
| + | { | ||
| + | // Set pin PB7 as output | ||
| + | DDRB = 0x80; | ||
| + | |||
| + | // Infinite loop | ||
| + | while (true) | ||
| + | { | ||
| + | // Invert pin PB7 | ||
| + | PORTB ^= 0x80; | ||
| + | hw_delay_ms(500); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | If compilation of this code is also successful, the development environment was set up correctly. | ||
| + | |||
| + | < | ||
| + | |||
| + | ===== Loading the code into microcontroller ===== | ||
| + | |||
| + | **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.** Set options for program loader (AVRDude). For this again open project properties //Project -> Properties// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | It is important to check that in list // | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | **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. | ||
| + | |||
| + | 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! | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Using floating-point variables ===== | ||
| + | |||
| + | It is sometimes necessary in AVR programs to use floating-point variables. For calculating with them and presenting with // | ||
| + | |||
| + | **1.** Open the configuration of the project from the menu //File → Properties// | ||
| + | |||
| + | **2.** Then open //AVR C Linker → General// and into box of //Other Arguments// add line // | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | **3.** Press OK and close configuration window. | ||