IDE CodeBlocks manual setup

The following guide describes the AVR development environment setup, if not used HomeLab precompiled installing package.

Installing software

It is necessary to install the following software bundle:

1. CodeBlocks CodeBlocks IDE (Integrated Development Environment), for software writing and its loading into the microcontroller.

2. ATMEL AVR Toolchain

AVR Toolchain is GNU-GCC compiler for AVR microcontrollers. This is a freeware which can be found on Atmel's website.

3. HomeLab library

HomeLab library contains a various functsions to make AVR and HomeLab kit programming simpler. The last versions for this library can be found on HomeLab website.

4. DFU-Programmer

DFU-Programmer is for programming HomeLab III series controller and using its bootloader


CodeBlocks installation

Following guide describes HomeLab III (Controller v1 - ATxmega128A1U) development enviroment setup and use in Windows operating system.

First install CodeBlocks software. No need to install CodeBlocks plugis.

Next choose correct location for CodeBlocks. All examples are in default location C:\HomelabCB Then CodeBlocks software install on the computers.

Adding Homelabs extras

When CodeBlocks are installed, then add: AVR Toolchain, HomeLab library, DFU-Programmer

First of all, you should choose the folder where you installed the CodeBlocks, because of all the extras installed in the same folder.

CodeBlocks setup

The first launch prompted compiler location. May be select *No Compiler*, because the choice of the compiler is set manually at a later, and it is dependent to the project template.

Then, the compiler should be set. Enter the menu Settings → Compiler…. In the opened window should be set to the following lines: Observe that would be selected GNU GCC Compiler for AVR and show where to install the software. If the installed sowtware location is not C:\HomelabCB then should be made corresponding changes themselves.

Then configure the programmer to be able to download the code directly from CodeBlocks environment. In order to find the menu Tools → Configure tools… and choose Add. In the opened windows write the following rows dependent HomeLabs generation:

HomeLab III

  • Homelab III
  • C:\HomelabCB\Programmer\Program.bat
  • “C:\HomelabCB\Programmer” “${TARGET_OUTPUT_BASENAME}.hex”
  • ${TARGET_OUTPUT_DIR}

HomeLab II (Atmega2561)

  • Homelab 2561
  • C:\HomelabCB\Programmer\HL Flash\hlflash.exe
  • ${TARGET_OUTPUT_BASENAME}.hex
  • ${TARGET_OUTPUT_DIR}

Linux/Ubuntu setup

Install Codeblocks extras:

sudo apt-get install codeblocks-contrib

To run dfu-programmer with a normal user privileges, create under /etc/udev/ folder a ruled.d file with following content:

SUBSYSTEM=="usb",ACTION=="add",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="*",GROUP="plugdev"

It is also necessary to install the library. Typically AVR libraries are located in the folder /usr/lib/avr It is necessary to own administrator rights to add a folder for the new library.

If the AVR Toolchain repositorys not yet been updated, you may receive an error message for ADC function. To correct this replace manually in the avr folder iox128a1u.h file (included in the library).

To make programming simpler create a following batch file:

sudo nano /usr/bin/homelab-programmer

copy the content of the file:

#!/bin/bash
dfu-programmer atxmega128a1u erase
dfu-programmer atxmega128a1u flash $1
dfu-programmer atxmega128a1u start

crant execution permission:

sudo chmod 775 /usr/bin/homelab-programmer

Codeblocks Tools→Configure tools … Set the programmer is as follows.

Add library support Settings → Compiler …

CodeBlocks creating a project

Go to menu File→New→Project. There should be selected a project according to HomeLab version and configure it as desired.

First, choose the name and location of the project. Avoid the use of umlauts. Then select the project compiling folder. It is recommended to not change it. Then choose a microcontroller and used frequency. Lastly, AVR Toolchain installation folder should be set.

Using the CodeBlocks

Once the project is created, then the new project appears in the left tree with example code. To compile press the gear icon in the toolbar. If the compilation succeeds then in the bottom Build Log window the user program memory count are displayed or if not, then error messages in the event of failure.

When loading the program into the microcontroller, in case HomeLab III, first should be entered into the bootloader by holding down the button S0 on the Controller module and at the same time, press the reset button to restart. In previous HomeLabs a bootloader mode is not available. If all the necessary drivers are installed (drivers are in CodeBlocks / Programmer folder), then can be download compiled hex file. To start programmer, go to Tools menu.

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