Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en:examples:setup:avrstudio:atmega2560 [2012/05/29 14:52] raivo.sellen:examples:setup:avrstudio:atmega2560 [2026/02/19 11:30] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== AVR Studio for Windows ATmega2561 ======+====== AVR Studio ATmega2561 ======
  
-<note important>Needs translation</note> 
  
-===== Projekti loomine =====+===== Creating a project =====
  
-Kui arendustarkvara on paigaldatud saab alustada programmi kirjutamist+After the development software is installed you can start writing code
-AVR kontrolleri programmi kirjutamiseks tuleb luua uus projektmis tüüpiliselt sisaldab endas palju erinevaid faileprogrammikoodi(e)päisfailekompileeritud programmi jneSelleks et projektid oleks korrektselt eristatavadtuleks iga projekti jaoks luua uus kataloog (seda võimalust pakub uue projekti loomise abimees).+To write programs for the AVR controller you must create a new projectwhich typically contains many different filessource code, header filescompiled programetcTo keep projects separateit is best to create a new folder for each project (the new project wizard offers this option).
  
-Uue projekti loomiseks tuleb läbida järgmised sammud:+To create a new project, follow these steps:
  
-**1.** Avada AVR Studio ja vajutada nupule uus projekt (//New Project//)Juhul kui vastav aken automaatselt ei avanevalida menüüst //Project - New project//Pärast sobivat sisestust vajutada nupule //Next//.+**1.** Open AVR Studio and press the New Project buttonIf the window does not open automaticallychoose //Project - New project// from the menuAfter entering the required information press //Next//.
  
 {{  :software:avrstudio:avrstudio_newproject0.png?400  |}} {{  :software:avrstudio:avrstudio_newproject0.png?400  |}}
  
-**2.** Avaneb aken, kus tuleb märkida kompilaatori ja failide algseadedKompilaatoriks valida AVR GCC ja paremas akna osas sisestada projekti nimi ning algkoodi faili nimiAlgkoodi faili nimi peaks kindlasti lõppema laiendiga ".c"Aknas on võimalik veel märkida valikud automaatseks projekti nimega kataloogi ja algkoodi faili tekitamiseksMõlemad valikud on mõistlik ära märkidaSamuti tuleks näidata kataloogkuhu vastav projektikataloog tekitatakse. Pärast valikute tegemist vajutada nupule //Next//.+**2.** A window opens where you set compiler and file defaultsChoose AVR GCC as the compiler and enter the project name and the main source file name on the right sideThe source file name should end with the ".c" extensionYou can also select options to automatically create a folder with the project name and the main source fileBoth options are recommended. Also specify the directory where the project folder should be createdAfter selecting optionspress //Next//.
  
-NB! Kui kompilaatori valikus puudub AVR GCC, siis ei ole WinAVR korrektselt paigaldatud ja seda tuleks enne C-keele programmi kirjutamist kindlasti teha.+NB! If AVR GCC is missing from the compiler list, WinAVR is not installed correctly and must be installed before writing programs.
  
 {{  :software:avrstudio:avrstudio_newproject1.png?400  |}} {{  :software:avrstudio:avrstudio_newproject1.png?400  |}}
  
-**3.** Järgnevalt avaneb akenkus tuleb märkida kasutatav silumise platvorm ja mikrokontrolleri tüüpKodulaboris (v5) on silumise platvormina kasutusel //JTAGICE mkII// programmaator ja mikrokontrolleriks on //ATmega2561//Projekti lõplikuks loomiseks vajutada nupule //Finish//.+**3.** Nexta window opens where you select the debug platform and microcontroller typeIn HomeLab (v5) the debug platform is //JTAGICE mkII// and the microcontroller is //ATmega2561//To finish creating the project, press //Finish//.
  
 {{  :software:avrstudio:avrstudio_newproject2.png?400 |}} {{  :software:avrstudio:avrstudio_newproject2.png?400 |}}
  
-**4.** Nüüd avaneb juba programmeerimise kasutajaliides, kuhu saab hakata kirjutama programmi lähtekoodi.+**4.** Now the programming interface opens and you can start writing the program source code.
  
 {{  :software:avrstudio:avrstudio_newproject3.png?500  |}} {{  :software:avrstudio:avrstudio_newproject3.png?500  |}}
  
-~~PB~~+<pagebreak>
  
-**5.** Enne koodi kompileerimist tuleb määrata projekti seadedOlulisemad seaded on kontrolleri taktsagedus ja kompilaatori optimeerimismeetodKodulabori kontrolleri taktsagedus on 14,7456 MHz ehk 14745600 Hz. See sagedus tuleb hertsides määrata //Project -> Configuration Options -> General// aknasOptimeerimise meetodiks jätta -Os, kui ei ole konkreetset vajadust teiste meetodite järgi.+**5.** Before compiling the code, set the project optionsThe most important settings are the controller clock frequency and the compiler optimization methodThe HomeLab controller clock frequency is 14.7456 MHz, i.e., 14745600 Hz. Enter this frequency in hertz in //Project -> Configuration Options -> General//Use -Os for optimization unless you have a specific reason to use another method.
  
 {{  :software:avrstudio:avrstudio_newproject4.png?400  |}} {{  :software:avrstudio:avrstudio_newproject4.png?400  |}}
  
-**6.** Kodulabori teegi kasutamine AVR Studio-ga eeldab, et see on tarkvara paigaldamise juhendi kohaselt süsteemi paigaldatudIga projekti korral tuleb teek projekti seadetest //Project -> Configuration Options -> Libraries// lisada lingitavate objektide nimekirja.+**6.** Using the HomeLab library with AVR Studio requires that it is installed on the system according to the software installation guideFor each project, add the library to the list of objects to link in //Project -> Configuration Options -> Libraries//.
  
 {{  :software:avrstudio:avrstudio_newproject5.png?400  |}} {{  :software:avrstudio:avrstudio_newproject5.png?400  |}}
  
-Kui objekt //libhomelab2561.a// nimekirjast puudubsiis ei ole Kodulabori teek korrektselt süsteemi paigaldatud+If the object //libhomelab2561.a// is missing from the listthen the HomeLab library has not been installed correctly
  
-~~PB~~+<pagebreak>
  
-===== Seadistuste testimine =====+===== Testing the configuration =====
  
-Kui arenduskeskkond on esimest korda paigaldatud ja seadistatudon mõistlik testida, kas kõik sai tehtud õigestiSelleks on lihtsaim viis teha üks väike programmsee ära kompileerida ja laadida kontrollerisse+If the development environment is installed and configured for the first timeit is good to test that everything was done correctlyThe easiest way is to write a small program, compile itand upload it to the controller
  
-**1.** Ühendada kontrollerplaat USB kaabliga arvutigaPeale kontrollerplaadi ühendamist peaks süttima väike roheline toite LED PWR. +**1.** Connect the controller board to the computer with a USB cableAfter connecting the board, a small green power LED (PWR) should light up
  
-**2.** Käivita liidesprogramm HappyJTAG2 ja seejärel AVR Studio. Oluline on sammude järjekordEsmalt tuleb ühendada kontroller arvutiga ja veenduda, et kontroller lülitub sisseSeejärel käivitada programm HappyJTAG2 ja AVR Studio. +**2.** Start the HappyJTAG2 interface program and then AVR Studio. The order is importantFirst connect the controller to the computer and verify it powers onThen start HappyJTAG2 and AVR Studio. 
  
-**3.** AVR Studios luua vajadusel projekt ja sisestada lihtne C-kood:+**3.** Create a project in AVR Studio if needed and enter simple code:
  
-Testida võib kahte erinevat koodiEsimene neist kasutab Kodulabori teekiteine teeb sama asja ilma teegita.+You can test two different codesThe first uses the HomeLab librarythe second does the same without the library.
  
 <code c> <code c>
-//Lihtne testprogramm, mis kasutab Kodulabori teeki.+// Simple test program using the HomeLab library.
 #include <avr/io.h> #include <avr/io.h>
 #include <homelab/delay.h> #include <homelab/delay.h>
Line 61: Line 60:
 int main(void) int main(void)
 { {
- // Viigu PB7 seadmine väljundiks+ // Set PB7 as output
  DDRB = 0x80;  DDRB = 0x80;
  
- // Lõputu tsükkel+ // Infinite loop
  while (true)  while (true)
  {  {
- // Viigu PB7 inverteerimine+ // Toggle PB7
  PORTB ^= 0x80;  PORTB ^= 0x80;
  hw_delay_ms(500);  hw_delay_ms(500);
Line 75: Line 74:
  
 <code c> <code c>
-//Lihtne testprogramm, mis ei kasuta Kodulabori teeki.+// Simple test program that does not use the HomeLab library.
 #include <avr/io.h> #include <avr/io.h>
    
Line 81: Line 80:
 { {
  unsigned int x,y;  unsigned int x,y;
- // Viigu PB7 seadmine väljundiks+ // Set PB7 as output
  DDRB = 0x80;  DDRB = 0x80;
    
- // Lõputu tsükkel+ // Infinite loop
  while (1)  while (1)
  {  {
- // Viigu PB7 inverteerimine+ // Toggle PB7
  PORTB ^= 0x80;  PORTB ^= 0x80;
  y=3200;  y=3200;
Line 102: Line 101:
  
  
-[{{  :examples:install:windows:studio_quick_buttons.png?267  |Kompileerimise ja programmaatori nupud}}]+[{{  :examples:install:windows:studio_quick_buttons.png?267  |Compile and programmer buttons}}]
  
-Kompileerida programm käsuga //Build// (kiirklahv F7) ja kontrollida, et kompileerimine õnnestusSelleks peab teadete aknasse tekkinud kompilaatori väljundi lõpp olema järgmine+Compile the program using //Build// (shortcut F7) and verify the compile succeededThe end of the compiler output in the message window should be:
  
   Build succeeded with 0 Warnings...   Build succeeded with 0 Warnings...
  
-~~PB~~+<pagebreak>
  
-**4.** Avada koodi laadimise aken nupust //Tools -> Program AVR -> Auto Connect//Tulemuseks peaks avanema kompileeritud faili mikrokontrollerisse laadimise akenKontrollige, et avatud oleks kaart //Program//.+**4.** Open the programming window using //Tools -> Program AVR -> Auto Connect//This opens the window for uploading the compiled file to the microcontrollerMake sure the //Program// tab is open.
  
 {{  :software:avrstudio:avrstudio_prog.png?400  |}} {{  :software:avrstudio:avrstudio_prog.png?400  |}}
  
  
-Kui eespool toodud aken ei avane ja avaneb aken //Connection Failed//, siis puudub ühendus programmaatorigaEsmalt tuleks kontrollida, kas mikrokontrolleril on järel toideKui see on korrassiis tuleks kontrollida HappyJTAG2 programmi oleku indikaatoreid. FT2232 ja AVRStudio peaks olema rohelised.+If the above window does not open and you see //Connection Failed//, then there is no connection to the programmerFirst check that the microcontroller has powerIf it doescheck the HappyJTAG2 status indicators. FT2232 and AVRStudio should be green.
  
 {{  :software:jtag:happyjtag2.png?400  |}} {{  :software:jtag:happyjtag2.png?400  |}}
  
-**5.** Programmaatori aknas sisestada //Flash//-sektsioonis tekstikasti //Input HEX File// kompileeritud failSeda saab teha "..." nuppu vajutadesKompileeritud fail asub tavaliselt projekti alamkataloogis //default// ja see on sama nimegamis projekt, kuid laiendiga ".hex", näiteks "labor1.hex"Pärast õige faili valimist vajutada nupule //Program//, mis laeb valitud programmi kontrollerisseKui kõik õnnestustekib programeerimiskeskkonna allosasse teade:+**5.** In the programmer window, enter the compiled file in the //Input HEX File// field in the //Flash// sectionYou can use the "..." buttonThe compiled file is usually in the project subfolder //default// and has the same name as the projectbut with the ".hex" extensionfor example "labor1.hex"Then press //Program// to upload the selected program to the controllerIf everything succeedsa message appears in the lower part of the programming interface:
  
   OK   OK
Line 131: Line 130:
   Leaving programming mode.. OK   Leaving programming mode.. OK
    
-Programmi mõjul peaks kontrolleri plaadil olev oleku-LED PB7 perioodiliselt süttima ja kustumaKui programm töötabon tarkvara paigaldatud edukalt ja esimene projekt tehtudPalju õnne!+The program should cause the PB7 status LED on the controller board to blink periodicallyIf it worksthe software installation is successful and your first project is doneCongratulations!
  
 {{:kit:kit_2561_test.jpg?400|}} {{:kit:kit_2561_test.jpg?400|}}
  
-===== Siluri kasutamine =====+===== Using the debugger =====
  
-[{{  :examples:install:windows:studio_debugger_io_view.png?280|ATmega registrite loetelu siluris}}]+[{{  :examples:install:windows:studio_debugger_io_view.png?280|List of ATmega registers in the debugger}}]
  
-Programmi silumiseks (inglise keeles //debugging//) nimetatakse vigade otsimist programmistSelleks on loodud eraldi vahendid - silurid (inglise keeles //debugger//)mis võimaldavad programmi täita samm-sammult, peatades seda soovitud kohtadesSelline programmi täitmine võimaldab igas programmi faasis kontrollida muutujate väärtusiregistrite sisusid ja programmi täitmise järjekorda. Eriti oluline on silumise võimaluse kasutamine keerukamate programmide juureskus vea põhjust on tihti keeruline otsidaMikrokontrollerite puhul on veel olulineet 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 peab olema silumist toetav riistvara JTAG programmaatorOdavamad programmaatoridmis kasutavad ISP programmeerimise liidestvõimaldavad laadida kontrollerisse kompileeritud programmikuid ei võimalda silumist.+Debugging is the process of finding errors in a programFor this purpose debuggers are usedwhich allow the program to run step-by-step and stop at desired pointsThis makes it possible to inspect variable valuesregister contentsand the execution order at each stageDebugging is especially important for complex programs where the cause of errors can be difficult to find. In microcontrollersstep-by-step execution runs in the controller itself and also allows you to see real output changes, in addition to register valuesTo use debuggingtwo conditions must be met: the microcontroller must support debuggingand you must have debugging hardwarei.e., a JTAG programmer. Cheaper programmers that use ISP can upload the compiled program but cannot debug.
  
-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 katkestuspunktinipeatatakse programmi töö, võimaldades nii uurida mikrokontrolleri olekut sellesse punkti jõudmiselProgrammi 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).+To run a program in debug mode with AVR Studio, first compile with //Build// (F7) and then start the compiled program with //Run// (F5). You can set break points in the source code before this (F9). When program execution reaches a break pointexecution stops and you can inspect the microcontroller state at that pointYou can continue with //Run// or step through using //Step Into// (F11).
  
-===== Ujukoma-arvude kasutamine =====+===== Using floating point numbers =====
  
-Mõnikord tekib vajadus AVR programmis kasutada ujukoma-arveNendega arvutamiseks ja nende esitamiseks //printf//-tüüpi funktsioonidega tuleb projekti seadistustes teha järgmised muudatused:+Sometimes you need to use floating point numbers in AVR programsTo calculate with them and use //printf//-style functions, make the following changes in project settings:
  
-**1.** Avada projekti seaded menüüst //Project -> Configuration Options//Seadete kaardil //Libraries// tuleb sinnakuhu on lisatud Kodulabori teegi objekt //libhomelab.a//, järgi lisada ka //libprintf_flt.a// ja //libm.a//.+**1.** Open project settings via //Project -> Configuration Options//On the //Libraries// tabafter //libhomelab.a// add //libprintf_flt.a// and //libm.a//.
  
-**2.** Seejärel tuleb avada //Custom Options// kaart ja valida //[All files]// sektsioonParempoolsesse kasti lisada read "-lprintf_flt" ja "-lm". //[Linker Options]// sektsiooni lisada rida "-uvfprintf".+**2.** Open the //Custom Options// tab and select the //[All files]// sectionAdd "-lprintf_flt" and "-lm" to the right-hand boxIn the //[Linker Options]// section add "-uvfprintf"
 + 
 +**3.** Press OK and close the settings window.
  
-**3.** Vajutada OK ja sulgeda seadete aken. 
en/examples/setup/avrstudio/atmega2560.1338292364.txt.gz · Last modified: (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