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
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"
Device Selection
In the Device Selection choose your device (here: ATmega328)
Atmel Studio 6 creates the solution and the project. The file m2u8.c can be removed.
Add Library Files
Add the library files to the static library project "m2u8". Right click on project name, Add Existing Item...
Mark all files, press "Add".
The solution explorer should look like this:
Edit Project Properties
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.
Tab: Optimization
- Optimization Level: Optimize for size
- Other optimization flags: -fdata-sections
- Enable "Prepare functions for garbage collection"
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".
GCC C Executable
Enter the name of the new GCC C Executable Project ("file_select")
Select a device as seen above.
Remove Generated File
Remove the automatic generated file.
Add Example Code ("file_select")
Add existing item: Add the file_select.c file from the example directory
Result should be:
Project Dependencies
Set the project dependencies for "file_select"
Startup Project
Set "file_select" as startup project
Properties of the "file_select" Project
Modify properties of the "file_select" project.
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)
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"
Tab: Toolchain, Compiler Directories
Toolchain->All Configurations->AVR/GNU C Compiler->Directories
Add relative include path: "....m2u8"
Tab: Toolchain, Linker Optimization
Toolchain->All Configurations->AVR/GNU Linker->Optimization
Enable "Garbage collect unused sections"
Tab: Toolchain, Linker Libraries
Toolchain->All Configurations->AVR/GNU Linker->Libraries
Add Library "m2u8"
Tab: Toolchain, Library Path
Toolchain->All Configurations->AVR/GNU Linker->Libraries
Add Library search path (relative) "....m2u8\Debug"
Build
Output result:
The result (elf and hex files) are aviable in the "Output Files" Folder of the Solution Explorer:
Flash
Connect your programmer (here: AVRISP mkII)
Device Programming
Call Tools->Device Programming
Press Apply Button, Read the device Id. Ensure that the device Id matches the selected Device.
Select the production file.
Enable "Flash" and select "Program":
Target System
- DOGM132 Display
- ATmega328 with 8 MHz
- 2xAA power supply