Up: AVRLIB


Other important configuration files

Once you start with your own projects you should have a directory for each program you write. In each project directory there should be a 'global.h' configuration file and also each project should have its own 'makefile'. For example if you have a project called 'blink', there should be a directory called 'blink' and inside that directory you should your 'global.h' file a 'makefile' for compiling your code and a 'blink.c' file with your code.

In case of Wiring its crystal or clock speed runs at 16MHz therefore the file 'global.h' should look something like:


 		        
 
#ifndef GLOBAL_H
#define GLOBAL_H

// global AVRLIB defines
#include "avrlibdefs.h"
// global AVRLIB types definitions
#include "avrlibtypes.h"

// project/system dependent defines

// CPU clock speed
#define F_CPU        16000000                           // 16MHz processor
//#define F_CPU        14745000                         // 14.745MHz processor
//#define F_CPU        8000000                          // 8MHz processor
//define F_CPU        7372800                           // 7.37MHz processor
//#define F_CPU        4000000                          // 4MHz processor
//#define F_CPU        3686400                          // 3.69MHz processor
#define CYCLES_PER_US ((F_CPU+500000)/1000000)  // cpu cycles per microsecond

#endif

Makefiles are unique for each project since they help on compiling and uploading code for each project. You will find examples of 'makefiles' on the hands-on examples later on this article.

For more on ``Makefiles'' you can take a look at the Make Manual. Also on the CCRMA Wiki at AVR_Programming Makefiles. An example 'makefile' for project blink can be seen as: makefile.blink .


next up previous
Next: AVR-GCC Up: AVRLIB Previous: Configuration

© Copyright 2001-2008 CCRMA, Stanford University. All rights reserved.
Created and Mantained by Juan Reyes