Porting From IAR to AVR GCC
Introduction
C language was designed to be a portable language. There two main types of porting activities: porting an application to a different platform (OS and/or processor), and porting to a different compiler. Porting to a different compiler can be exacerbated when the application is an embedded system. For example, the C language Standard, strangely, does not specify a standard for declaring and defining Interrupt Service Routines (ISRs). Different compilers have different ways of defining registers, some of which use non-standard language constructs.
This chapter describes some methods and pointers on porting an AVR application built with the IAR compiler to the GNU toolchain (AVR GCC). Note that this may not be an exhaustive list.
Registers
IO header files contain identifiers for all the register names and bit names for a particular processor. IAR has individual header files for each processor and they must be included when registers are being used in the code. For example:
#include <iom169.h>
-
Note:
- IAR does not always use the same register names or bit names that are used in the AVR datasheet.
AVR GCC also has individual IO header files for each processor. However, the actual processor type is specified as a command line flag to the compiler. (Using the -mmcu=processor flag.) This is usually done in the Makefile. This allows you to specify only a single header file for any processor type:
#include <avr/io.h>
-
Note:
- The forward slash in the < avr/io.h> file name that is used to separate subdirectories can be used on Windows

本文档介绍了如何将使用IAR编译器构建的AVR应用移植到GCC工具链。主要内容包括:注册、中断服务例程(ISRs)、内联函数、闪存变量和非返回主函数的处理差异。

1615

被折叠的 条评论
为什么被折叠?



