IAR开发环境配置与使用
- IAR版本:IAR for ARM 8.30.1
1.基础设置
- 字体:
- Tools >>> Options >>> Common Fonts
- Tools >>> Options >>> Editor >>> Colors and Fonts
这里的13找不到直接输入,注意13和12的显示效果天壤之别哦;
- Tools >>> Options >>> Common Fonts
效果如下:
- 配色:
-
Tools >>> Options >>> Editor >>> Colors and Fonts
这里建议修改Strings和User Keyword就好了,其他默认 -
Tools >>> Options >>> Editor >>> Setup Files
写一个文本文件,将用户自定义的关键字放进去然后指定位置即可:
-
int8_t
int16_t
int32_t
int64_t
uint8_t
uint16_t
uint32_t
uint64_t
int8
int16
int32
int64
uint8
uint16
uint32
uint64
s32
s16
s8
u32
u16
u8
ft32
BOOL
TRUE
FALSE
效果如下:
- 缩进:
- Tools >>> Options >>> Editor
- Tools >>> Options >>> Editor
- 自定义快捷键:
- Tools >>> Options >>> Key Bindings
这里说一个最常用的go to define,F12很好用,但是有的联想笔记本很恶心,F12键的功能要加Fn才能触发,这时就可以自己修改快捷键了:
-
常用快捷键
- CTRL+SHIFT+SPACE 模版使用(包括if、for、class等);//新版本Ctrl+alt+V
- CTRL+B 括号匹配 选择括号内的多行代码;
- CTRL+T 自动缩进,格式化选中代码
- CTRL+SHIFT+K 取消快注释,取消屏蔽选中的代码;
-
- Tools >>> Options >>> Key Bindings
2.工程设置
- 预处理器
- 优化等级
- 向量表 堆栈 设置
- 输出可执行文件格式设置
3.调试方法与技巧
- 像Keil那样实时查看数据变化:仿真下View >>> Live Watch
设置数据的刷新频率:单位ms
- 查看寄存器:
新版的IAR查看寄存器隐藏了起来,这样找到它:
4. 代码注释
- 编辑模板,在空白界面下右键->Insert Template->Edit Templates
- 复制以下模板内容
################################################################################
##
## This is an example file for defining your own code templates.
##
## The syntax for defining a code template is:
## #TEMPLATE <template name>,<field>[=default value], <field>...
##
## The template name, the fields and their default values should be defined
## within quotes if they contain non-alphanumeric characters.
## Use "&" in front of a letter in the template name to make the letter become
## a shortcut, which means that you can use ALT+<letter> to select the template
## or jump to the field in the dialog box.
## Use ">" in the template to organize the template names in submenus.
##
################################################################################
#TEMPLATE "&Statement>&if"
if( %c )
{
}
#TEMPLATE &Statement>&for,"&End Value"=10,&Variable=i
for(int %2 = 0; %2 < %1; ++%2)
{
%c
}
#TEMPLATE &Corporate>&class,"Class &name",&Description=--,&Created="$DATE$, by $USER_NAME$"
//******************
// CLASS: %1
//
// DESCRIPTION:
// %2
//
// CREATED: %3
//
// FILE: $FILE_FNAME$
//
class %1
{
public:
%1();
~%1();
%c
};
#TEMPLATE "&FileDeclare>&FileVersion",&Author="tangyang",&date="$DATE$",&softwareVer="V0.01",&hardwareVer="V0.01",&Company="cpmpany"
/**
* *********************************************************************
* Copyright (c) 2021 %5 Co.Ltd. All Rights Reserved.
* @file $FILE_FNAME$
* @author %1
* @date %2
* @softwareVer %3
* @hardwareVer %4
* @brief
*
* *********************************************************************
* @note
* Date Version Author Notes
* %2 %3 %1 Build
* *********************************************************************
*/
/************************ (C) COPYRIGHT %5 *****END OF FILE**************/
#TEMPLATE "&FileDeclare>&FileSource",&version="V1.0",&date="$DATE$",&Author="tangyang",&Company="cpmpany"
/**
* *********************************************************************
* Copyright (c) 2021 %4 Co.Ltd. All Rights Reserved.
* @file $FILE_FNAME$
* @version %1
* @date %2
* @brief
*
* *********************************************************************
* @note
*
* *********************************************************************
* @author %3
*/
/* Includes ------------------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/************************ (C) COPYRIGHT %4 *****END OF FILE**************/
#TEMPLATE "&FileDeclare>&FileHeader",&version="V1.0",&date="$DATE$",&Author="tangyang",&Company="cpmpany"
/**
* *********************************************************************
* Copyright (c) 2021 %4 Co.Ltd. All Rights Reserved.
* @file $FILE_FNAME$
* @version %1
* @date %2
* @brief
*
* *********************************************************************
* @note
*
* *********************************************************************
* @author %3
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef $FILE_FNAME$
#define
/* Includes ------------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported variables --------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
#endif
/************************ (C) COPYRIGHT %4 *****END OF FILE***************/
#TEMPLATE &Doxygen>&Function,&brief=--,¶m=--,&return=--,&details=--
/**
* @brief %1
* @param %2
* @retval %3
* @details %4
*/
void fun(void)
{
%c
}
- 使用模板
配置文件链接:https://download.csdn.net/download/qq_18628523/16269265