This is an old revision of the document!


Installation instructions for Windows

this section contains the information necessary to install AVR development software on Windows operating system.

Installation

You need the following software which can be downloaded from manufacturers homepage or acquired from the CD supplied with the HomeLab Kit.

1. AVR Studio

AVR Studio 4 IDE (Integrated Development Environment) is a base software for writing the source code, compiling it and uploading the program to the controller. AVR Studio can be downloaded from Atmel homepage.

2. WinAVR

WinAVR is a GNU-GCC compiler for AVR microcontrollers. This is a freeware which can be downloaded from Sourceforge webpage. During the installation process WinAVR offers a folder name containing long version number. We suggest to cut the version number from folder name and install it just like shown below:

C:\WinAVR

3. HomeLab library

HomeLab library is a set of functions designed for HomeLab Kit and AVR controllers. By using the library the programming is much easier and effective. Latest version of the library can be downloaded from the HomeLab webpage. This library should be installed to the same folder where WinAVR was installed.

4.. Virtual COM port driver

Driver enables to connect USB JTAG-ICE programmer with your PC. Driver have to be installed before connecting the programmer. Driver file name is “CDM x.xx.xx.exe”, where “x” denotes the version number. After installing the driver you can connect the JTAG-ICE programmer through the USB port and let Windows to detect the device automatically. You should see the notice on the windows task bar.

Notice of finding the new device

According to number of virtual ports defined before on the particular computer the windows assigns next port number for the new device. New COM port name (range number) will be also generated when the device is plugged another USB port on the same computer. Some AVR Studio versions can not use the programmer if the COM port number exceeds number 10 and number 4 in case of using it as debugger. To prevent this situation you can modify the assigned port number in Device manager and assign it to the range COM0…COM4. 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

The list of registers in the debugger of the ATmega128.

Debugging a program means searching faults in the program. To do that programs called debuggers are created, they allow observing the program step by step and stopping the program where it is needed. Such implementation of the program allows checking the values of the variables at any phase of the program, contents of the registers and the sequence of executing the program. Especially important is using debugging when dealing with more complex programs where it is often difficult to find faults. At microcontrollers, it is also important that implementing the program step-by-step is done in the controller and allows to see in addition to the values of the registers also change of real outputs. For using debugger, two conditions must be filled: microcontroller must support debugging and you must have necessary hardware – JTAG programmer which allows debugging. Cheaper programmers which are using ISP programming interface may upload compiled program into the controller but may not allow debugging.

To start the program in debugging mode with the AVR Studio, it should be first compiled by pressing button build (F7) and start the compiled program with the command Run (F5). To the source code of the program may be added break points where desired (F9). If the implementation of the program arrives to the break point, the program is stopped and the state of the microcontroller may be investigated at the moment of arrival to that point. Implementation of the program may be continued by giving command Run again or use implementing command by command, this is done with command Step Into (F11).

The usage of floating-point variables

Sometimes it is necessary to use floating-point variables int the program of AVR. When calculating with these and presenting them with printf-type functions following set-up changes must be done to the configuration of the project:

1. Open the set-up of the project from the menu Project → Configuration Options. On the configuration tab Libraries comes where the object libhomelab.a of the library of the HomeLab was added, after that must be added also libprintf_flt.a and libm.a.

2. Next, Custom Options tab must be opened and [All files] section must be chosen. To the box on the right rows “-lprintf_flt” ja “-lm” must be added. To the [Linker Options] section must be added row: “-uvfprintf”.

3. Press OK and close configuration window.

en/examples/setup/windows.1267479385.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