This is an old revision of the document!


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, Eclipse AVR plugin, Robotic HomeLab library, HomeLab programming utilities and and example project.

MS Windows

Software download → Eclipse HomeLab package

Linux Ubuntu

Software download → Homelab-keyring

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 Workspace must be created. To do this, select the Workspace folder location in main window where the repository will be created.

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 ATmega2561 working frequency 14745600 Hz. To finish project setup click Finish.

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.

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 and navigate from leftside tree to General - Workspace and select option Save automatically before build

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.

//Lihtne testprogramm, mis ei kasuta Kodulabori teeki.
#include <avr/io.h>
 
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 ("nop");
    			}
  		} 
	}
}

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:

AVR Memory Usage
----------------
Device: atmega2561
Program:     308 bytes (0.1% Full)
(.text + .data + .bootloader)
Data:          0 bytes (0.0% Full)
(.data + .bss + .noinit)
Finished building: sizedummy

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.

../main.c: In function 'main':
../main.c:23: error: expected ';' before 'while'
../main.c:13: warning: unused variable 'x'
make: *** [main.o] Error 1

Samuti on Problems aknas erinevad veateated ja vastav koht koodis märgitakse vea ikooniga.

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.

8. Edasi võib teegi testimiseks kopeerida alloleva testprogrammi lähtekoodi eelmise asemele ja üritada seda kompileerida. Kompileerimiseks võib kasutada klahvikombinatsiooni CTRL+B.

//Lihtne testprogramm, mis kasutab Kodulabori teeki.
#include <avr/io.h>
#include <homelab/delay.h>
 
int main(void)
{
	// Viigu PB7 seadmine väljundiks
	DDRB = 0x80;
 
	// Lõputu tsükkel
	while (true)
	{
		// Viigu PB7 inverteerimine
		PORTB ^= 0x80;
		hw_delay_ms(500);
	}
}

Kui ka selle koodi kompileerimine õnnestub, siis on kõik eelnevad seadistused tehtud õigesti.

 

Kontrollerile koodi laadimine

1. Ühendada kontrollerplaat USB kaabliga arvutiga. Peale kontrollerplaadi ühendamist peaks (esmasel ühendamisel teatud aja pärast) süttima väike roheline toite LED - PWR.

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.

Oluline on kontrollida, et nüüd oleks Programmer configuration valikus midagi valida ja juhul kui eelnevalt midagi ei muudetud on selleks: New Configuration.

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.

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!

en/examples/setup/windows/eclipse_v5.1338196206.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0