KontrollerLab for Linux

The following guide describes the installation and use of the AVR toolkit 9:10 Ubuntu operating system.

Software Installation

Install the following software:

1. Linux software packages

  • gcc-avr – GNU C-language compiler for AVR
  • avrdude – Program for uploading hex-files to microcontroller
  • avr-libc – C language libraries to write code for AVR platform

To install the packages, use the terminal command:

sudo apt-get install gcc-avr avrdude avr-libc

or graphical installation software (such as Ubuntu software center or Synaptic packet manager).

2. HomeLab library

The library simplifies the writing of program code, since lower-level functions are ready-made. Visit the HomeLab website and download the file named Homelab library vX.X.run, where XX represents the version number. Run the following command to install the library:

sudo sh homelab_library_vX.X.run

Make sure that your library installation is successful.

3. KontrollerLab

KontrollerLab is an IDE (integrated development environment) for writing, compiling, loading and debugging AVR software. Download the KontrollerLab software and save it to some folder (for example, ~/Documents/AVR/KontrollerLab). Run the following command in this folder:

sudo dpkg -i kontrollerlab*.deb

If you have problems with packet dependencies, run the command which installs the missing packages:

apt-get install –f

Connecting the programmer

Connect to programmer with computer and see if the computer recognizes it. Write the command “lsusb” in the terminal window which should show the list of connected USB devices. Programmers name is “Future Technology Devices International, Ltd FT 232 USB-Serial (UART) IC”.

To get the port to which the programmer is connected to, check the /dev folder using the commands cd /dev (sets /dev as a current folder) and dir (displays the content of the folder). As the programmer is USB-serial interface, it is named as a “ttyUSBx” where “x” marks the index of the inteface. If there are no other USB-serial devices this number is zero.

Creating a new project

To write an AVR program, a project must be created which contains all the necessary files: source codes, header files, compiled program, etc. To clearly seperate projects, a folder for each project should be made (this option is also given by the project wizard).

To create a project follow the steps:

1. Open KontrollerLab (Applications → Programming → KontrollerLab) and start a new project from the File → New → New project menu . A window opens where the project location must be specified. In this example the locations is ../Homelab/blinkingLED/.

2. The project must have at least one C file where to write the program code. Files can be added from the File → New → New menu. In the opening window, select C source as a file type and specify the name of the file.

3. Next, the project must be configured for HomeLab kit. From the Project → Configure Project menu open the configurations window and select Common tab. CPU type should be ATmega128 and the clock should be 14745600,0 Hz. Also the names of the HEX and MAP files should be specified. Pressing a Set as default button makes these configurations as a default for new projects. This is reasonable when working only with HomeLab AVR microcontroller. As the HEX and MAP files are also stored as a default it is recommended to use some general name for them, for example “out.hex”.

NB! As the HomeLab library can not be added on the Linker configuration tab, the command “-lhomelab” must be added behind the name of the MAP file.

Apply settings on the Compiler tab as shown on the following screenshot. Before pressing OK set compiler configurations also as a default.

4. Configure the programmer by opening the configurations window from the Project → Configure Programmer menu. Choose “AVRDUDE” as a programmer. On the “AVRDUDE” tab set the programmer type to jtagmkI and connection port to /dev/ttyUSBx (where “x” is the port index). Set these configuration settings also as a default.

5. At last, place the windows in the KontrollerLab as it is more convenient and get ready to write your first program.

Writing and testing a program

After the configurations steps are done, it is time to programm.

1. Connect the programmer with Controller module. Double-check if the programmer is correctly connected with a JTAG socket. The cable must head away from the board (look at the picture). Now connect the power supply and check if the green LED lights on the Controller board.

2. Write the following program in the Kontrollerlab file editor window and compile it:

#include <avr/io.h>
#include <homelab/delay.h>
 
int main(void)
{
	// Set pin PB7 as an output
	DDRB = 0x80;
 
	// Lõputu tsükkel
	while (true)
	{
		// Inverting pin PB7
		PORTB ^= 0x80;
		hw_delay_ms(500);
	}
}
Toolbar

Make sure that the output window shows “File compiled successfully” message. If the “Error(s) occurred: ” message is shown, check the program code for mistakes.

3. To download the program into the Controller press the Ignite button. After the succeful download, the “Project built and uploaded successfully” message should be shown.

If everything was done correctly the red LED on the Controller board should blink periodically, with 1 second interval.

Using floating-point numbers

Sometimes it is neccessary to use floating-point numbers in program. To calculate with them and use them with printf-typed functions, some modifications in project configuration must be done:

1. Open the Project Configurations window and the Linker tab. Check the first line in the Linker flags list (look at the picture).

2. Press OK and close the window.

en/examples/setup/kontrollerlab.txt · Last modified: 2020/07/20 09:00 by 127.0.0.1
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