as6 - olikraus/m2tklib GitHub Wiki

Install m2tklib and u8glib: Tutoral and Step by step instructions for Atmel Studio 6

Extract Files

Extract files from the m2tklib_avr zip-archive

Start Atmel Studio 6 and create a new project

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/002.png

Create a new project

  • Choose "GCC C Static Library Project"
  • Choose and remember a name. This name is needed more often in this installation guide. The name "m2u8" will be used for the rest of this guide.
  • Enable "Create directory for new solution"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/003.png

Device Selection

In the Device Selection choose your device (here: ATmega328)

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/004.png

Atmel Studio 6 creates the solution and the project. The file m2u8.c can be removed.

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/005.png

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/006.png

Add Library Files

Add the library files to the static library project "m2u8". Right click on project name, Add Existing Item...

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/007.png

Mark all files, press "Add".

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/008.png

The solution explorer should look like this:

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/009.png

Edit Project Properties

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/010.png

Configuration: All Configurations

Tab: Toolchain, Symbols

Add Symbol "F_CPU=8000000UL" for a CPU which runs at 8MHz. Use a different value if your target system has a different CPU speed.

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/011.png

Tab: Optimization

  • Optimization Level: Optimize for size
  • Other optimization flags: -fdata-sections
  • Enable "Prepare functions for garbage collection"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/012.png

Create Example Project

Add New Project

Create a new project for one of the examples. Here: "file_select". Right click on the solution, "Add New Project".

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/014.png

GCC C Executable

Enter the name of the new GCC C Executable Project ("file_select")

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/015.png

Select a device as seen above.

Remove Generated File

Remove the automatic generated file.

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/016.png

Add Example Code ("file_select")

Add existing item: Add the file_select.c file from the example directory

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/017.png

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/013.png

Result should be:

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/018.png

Project Dependencies

Set the project dependencies for "file_select"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/019.png

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/020.png

Startup Project

Set "file_select" as startup project

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/021.png

Properties of the "file_select" Project

Modify properties of the "file_select" project.

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/022.png

Configuration: All Configurations

Tab: Toolchain, Symbols

Toolchain->All Configurations->AVR/GNU C Compiler->Symbols, Add Symbol

"F_CPU=8000000UL" (or any other value that fits to your target device)

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/023.png

Tab: Toolchain, Compiler Optimization

Toolchain->All Configurations->AVR/GNU C Compiler->Optimization

  • Optimization Level: Optimize for size
  • Other optimization flags: -fdata-sections
  • Enable "Prepare functions for garbage collection"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/024.png

Tab: Toolchain, Compiler Directories

Toolchain->All Configurations->AVR/GNU C Compiler->Directories

Add relative include path: "....m2u8"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/025.png

Tab: Toolchain, Linker Optimization

Toolchain->All Configurations->AVR/GNU Linker->Optimization

Enable "Garbage collect unused sections"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/026.png

Tab: Toolchain, Linker Libraries

Toolchain->All Configurations->AVR/GNU Linker->Libraries

Add Library "m2u8"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/027.png

Tab: Toolchain, Library Path

Toolchain->All Configurations->AVR/GNU Linker->Libraries

Add Library search path (relative) "....m2u8\Debug"

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/028.png

Build

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/030.png

Output result:

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/031.png

The result (elf and hex files) are aviable in the "Output Files" Folder of the Solution Explorer:

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/032.png

Flash

Connect your programmer (here: AVRISP mkII)

Device Programming

Call Tools->Device Programming

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/033.png

Press Apply Button, Read the device Id. Ensure that the device Id matches the selected Device.

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/037.png

Select the production file.

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/038.png

Enable "Flash" and select "Program":

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/atmel_studio_6/039.png

Target System

https://raw.githubusercontent.com/wiki/olikraus/m2tklib/pic/avr_file_select.jpg

  • DOGM132 Display
  • ATmega328 with 8 MHz
  • 2xAA power supply