This is an old revision of the document!


Instructions d’installation pour Windows

Cette partie contient l’ensemble des informations nécessaires à l’installation du logiciel de développement AVR avec le système d’exploitation Windows.

Installation

Pour réaliser cette installation vous devez disposer des logiciels suivant disponibles, en téléchargement, sur la page internet des fournisseurs ou sur le CD de support fournit dans le HomeLab Kit.

1. Studio AVR

Le Studio AVR 4 IDE (Integrated Development Environment) est le logiciel de base pour l’écriture des codes source, la compilation et le transfert du programme vers le contrôleur. Le Studio AVR peut être téléchargé depuis la page du site de la société Atmel.

2. WinAVR

WinAVR est un compilateur GNU-GCC pour microcontrôleurs AVR. Il s’agit d’un logiciel libre disponible en téléchargement sur la page internet de la société Sourceforge. Au cours de l’installation WinAVR propose un nom de dossier par défaut contenant un long numéro de version. Nous vous suggérons de remplacer ce nom de dossier par celui-ci :

C:\WinAVR

3. Librairie HomeLab

La librairie HomeLab est un ensemble de fonctions conçues pour le HomeLab Kit et les contrôleurs AVR. En utilisant cette librairie, la programmation devient bien plus facile et efficace. La dernière version de la librairie est disponible en téléchargement sur la page internet de HomeLab. Cette librairie doit être installée dans le même dossier d’installation du logiciel WinAVR.

4. Driver pour le port COM virtuel

Un driver est nécessaire pour connecter le programmeur USB JTAG-ICE avec votre ordinateur. Le driver doit être installé avant de connecter le programmeur. Le nom du fichier du driver est “CDM x.xx.xx.exe”, où les “x” correspondent au numéro de version. Après l’installation du driver vous pouvez connecter le programmeur JTAG-ICE grâce au port USB et laisser Windows détecter automatiquement le matériel. Vous devez voir la notification dans la barre des tâches Windows.

Notice of finding the new device

Selon le nombre de port virtuel défini précédemment, Windows assigne le numéro de port suivant au nouvel appareil. Un nouveau nom de port COM (numéro de série) est généré quand le matériel est connecté à un autre port USB du même ordinateur. Certaines versions du Studio AVR Studio ne peuvent pas utiliser le programmeur si le numéro du port COM excéde le nombre 10 et le nombre 4 est réservé au debugger. Pour remédier à cette situation vous pouvez modifier le numéro du port assigné dans le Device manager et le choisir parmi la liste COM0…COM4. See the complete procedure here . See the complete procedure here .

Creating new project

Writing a program for the controller you need to create the project space. The project includes typically different files like source codes, header files, compiled program files, etc. It is strongly suggested to create new folder for every project (which is offered also by the New Project Wizard).

Following steps have to be completed when creating new project with the help of wizard.

1. Open AVR Studio and press New Project. If the dialog box is not opened automatically select Project - New project from the menu bar. Press Next.

2. Next dialog box is about compiler and initial settings. Select AVR GCC compiler. On the left, insert the name of the project and main source file name. The source file name should have extension “.c”. Two check box should be also checked which will create then the new folder and initial file. You should also show the folder where project files will be created. After proper selections press Next.

NB! If AVR GCC is missing on the compiler list, it is not properly installed. In that case the WinAVR software have to be installed before starting to write C source code.

3. On the next dialog box you have to select the debugger platform and microcontroller. HomeLab Kit is using JTAG ICE as debugger platform and ATmega128 as microcontroller. After selections press Finish.

4. Now the project space is created and new window will open where you can start to write the program source code.

5. Before the first compilation you need to set some project parameters. The important parameters are controller frequency and optimization method. HomeLab controller has frequency 14,7456 MHz (14745600 Hz). The frequency can be set on the project properties with Hz (not MHz): Project → Configuration Options → General. Optimization method should left -Os, if there is no need for other methods.

6. For using HomeLab library functions the software have be properly intalled. Every new project requires to add library to list of linked objects. To do that got to Project → Configuration Options → Libraries and add object “libhomelab.a”.

If object libhomelab.a is missing on the left list the library is not properly installed to the system. You should resinstall it.

Setting's test

If the development environment is just set up it is reasonable to test to mbe sure that everything is correct. Simplest way is to write a short program, compile it and upload to controller.

1. Connect the programmer with ATmega128 board. Be sure that the programmer is connected correctly to JTAG connector (cable is directed away from controller board- see next picture). Connect the controller board supply (small green LED should light up if correct power supply is connected).

Insert simple C source code:

#include <avr/io.h>
#include <homelab/delay.h>
 
int main(void)
{
	// pin PB7 to output
	DDRB = 0x80;
 
	// endless cycle
	while (true)
	{
		// pin PB7 invertion
		PORTB ^= 0x80;
		hw_delay_ms(500);
	}
}
Compilation and programmer buttons

Compile the project with Build command (keyboard F7). Be sue that the compilation succeeded. For this you should see the following message on the message window.

  Build succeeded with 0 Warnings...

2. Open the controller window Tools → Program AVR → Auto Connect. Be sure that the tab Program is open.

If the described window does not open and Connection Failed window is opened instead you do not have proper connection with the board or programmer. First you should check that micrcontroller has correctly powered (green LED is on) and the programmer is properly connected to JTAG connector. If this is OK check the COM port number which is assigned by the Windows. If this is greater than 9, the AVR Studio can not recognize the programmer. Follow the instructions on the beginning of the document and assign the port number between 0 and 4.

3. On the programmer window insert into Flash-section textbox Input HEX File the location of the compiled program by pressing the “…” button.Compiled program is usually located in the project folder and sub folder default and has same name as the project but with the extension “.hex”, for example “labor1.hex”. After selecting correct file press button Program which uploads the program to the controller. If everything went well you should see the similar message on the end of the same window.

OK
Reading FLASH input file.. OK
Setting device parameters for jtag programming ..OK
Entering programming mode.. OK
Erasing device.. OK
Programming FLASH ..       OK
Reading FLASH ..       OK
FLASH contents is equal to file.. OK
Leaving programming mode.. OK

According to the program the on-board LED (PB7) should start flashing. If it works like this you have successfully set up your programming environment and completed your first program. Congratulations!

Debugger

ATmega128 registrite loetelu siluris

Programmi silumiseks (inglise keeles debugging) nimetatakse vigade otsimist programmist. Selleks on loodud eraldi vahendid - silurid (inglise keeles debugger), mis võimaldavad programmi täita samm-sammult, peatades seda soovitud kohtades. Selline programmi täitmine võimaldab igas programmi faasis kontrollida muutujate väärtusi, registrite sisusid ja programmi täitmise järjekorda. Eriti oluline on silumise võimaluse kasutamine keerukamate programmide juures, kus vea põhjust on tihti keeruline otsida. Mikrokontrollerite puhul on veel oluline, et tarkvara samm-sammult täitmine toimub reaalselt kontrolleris ja võimaldab nii lisaks registrite väärtuste vaatamisele näha ka reaalsete väljundite muutumist. Siluri kasutamiseks on eelkõige vaja kahte tingimust: kasutatav mikrokontroller peab silumist toetama ja olemas peab olema ka vajalik riistvara - silumist toetav JTAG programmaator. Odavamad programmaatorid, mis kasutavad ISP programmeerimise liidest, võimaldavad laadida kontrollerisse küll kompileeritud programmi, kuid ei võimalda silumist.

Programmi käivitamiseks siluri režiimis AVR Studio-ga tuleks see esmalt kompileerida nupuga Build (kiirklahv F7) ja käivitada kompileeritud programm käsuga Run (kiirklahv F5). Programmi lähtekoodi võib enne seda soovitud kohtadele lisada katkestuspunkte (inglise keeles break point) (kiirklahv F9). Kui programmi täitmine jõuab katkestuspunktini, peatatakse programmi töö, võimaldades nii uurida mikrokontrolleri olekut sellesse punkti jõudmisel. Programmi täitmist võib jätkata jällegi käsuga Run või siis kasutada käskhaaval täitmist käsuga Step Into (kiirklahv F11).

Ujukoma-arvude kasutamine

Mõnikord tekib vajadus AVR programmis kasutada ujukoma-arve. Nendega arvutamiseks ja nende esitamiseks printf-tüüpi funktsioonidega tuleb projekti seadistustes teha järgmised muudatused:

1. Avada projekti seaded menüüst Project → Configuration Options. Seadete kaardil Libraries tuleb sinna, kuhu on lisatud kodulabori teegi objekt libhomelab.a, järgi lisada ka libprintf_flt.a ja libm.a.

2. Seejärel tuleb avada Custom Options kaart ja valida [All files] sektsioon. Parempoolsesse kasti lisada read “-lprintf_flt” ja “-lm”. [Linker Options] sektsiooni lisada rida “-uvfprintf”.

3. Vajutada OK ja sulgeda seadete aken.

fr/examples/setup/windows.1266226652.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