# IAR相关知识点 ## 工程操作 ### 各类型文件含义 - **.eww**:Embedded Workbench Workspace(嵌入式工作台工作空间文件) 用于管理多个工程(.ewp 文件)的集合,记录工程的组织方式和打开状态。 - **.ewp**:Embedded Workbench Project(嵌入式工作台工程文件) 是 IAR 项目的核心文件,包含工程的配置信息(如编译选项、目标芯片、文件列表等)。 - **.ewd**:Embedded Workbench Debugger Configuration(嵌入式工作台调试器配置文件) 存储调试相关的设置,如断点、监视变量、调试器连接参数等。 - **.c**:C Source File(C 语言源文件) 通用的 C 语言源代码文件,并非 IAR 专属,所有 C 语言开发环境均可识别。 - **.dep**:Dependency File(依赖文件) 记录源文件之间的依赖关系(如头文件引用),用于编译系统判断文件是否需要重新编译。 - **.ewt**:Embedded Workbench Template(嵌入式工作台模板文件) 用于存储工程或文件的模板配置,方便快速创建具有相同设置的新项目。 - **.s** 或 **.asm**:Assembly Source File(汇编源文件) 包含汇编语言代码,用于编写对性能要求极高或直接操作硬件的程序段。 - **.h**:Header File(头文件) 存储函数原型、宏定义和类型声明,用于在多个源文件间共享接口定义。 - **.out**:Output File(输出文件) 编译链接后生成的中间文件,通常包含可执行代码和符号信息,可用于进一步处理。 ### 新建/打开工作区 ![image-20250708105919518](./pictures/image-20250708105919518.png) ### 新建/打开工程 ![image-20250708110035222](./pictures/image-20250708110035222.png) ### 工作区中导入/添加工程 ![image-20250708111507961](./pictures/image-20250708111507961.png) ### 新建分组 ![image-20250708121915830](./pictures/image-20250708121915830.png) ### 新建/打开文件 ![image-20250708122510344](./pictures/image-20250708122510344.png) ### 工程目录与文件目录的关系 工程目录就是像linux里面的软连接,实际文件还是存在他自己的地方, ## 工程配置 在工程文件中选择右键 选择`options`->`General options`->`target`->`Device`选择自己电脑所用的架构 ![image-20250708130710152](./pictures/image-20250708130710152.png) ## 编译配置 ### 优化等级 选择上述图片里面的`C/C++ Compiler`->`Optimizations` [说明地址](https://www.bmrtech.com/Tech/tech_show/50.html) ![image-20250708131625603](./pictures/image-20250708131625603.png) ### 硬件浮点 ![image-20250708132202198](./pictures/image-20250708132202198.png) ### 预处理 选择`options`->`C/C++ Compiler`->`preprocessor` ![image-20250710184018484](./pictures/image-20250710184018484.png) ### 链接文件 选择`options`->`Linker`->`linker configuration file` 链接脚本控制内存分配(Flash/ROM、RAM 布局)关键硬件相关文件 ![image-20250708133445445](./pictures/image-20250708133445445.png) ### 文件路径配置 选择`options`->`C/C++ Compiler`->`preprocessor` ![image-20250710184547839](./pictures/image-20250710184547839.png) ### 输出文件配置 选择`options`->`Output Converter`选择生成的文件格式和文件名称 ![image-20250708133903502](./pictures/image-20250708133903502.png) ### 输出文件路径配置 点击`options`>`General Optons`>`Output` ![image-20250710184648034](./pictures/image-20250710184648034.png) ## 调试器配置 选择`options`->`Debugger`选择要烧录进单片机的方式 ![image-20250708134300137](./pictures/image-20250708134300137.png) ## 库相关配置 `options`->`General options`->`Liabrary Configuration` ![image-20250708134436504](./pictures/image-20250708134436504.png) ## 静态库的封装 创建一个项目,编写好函数,右键项目`options`->`General options`->`Output`选择生成的文件是Library ![image-20250710091818054](./pictures/image-20250710091818054.png) 2. 如果要屏蔽不想生成的文件可以把`Exclude from build` ![image-20250710092312114](./pictures/image-20250710092312114.png) 3. 选择生成的路径 ![image-20250710185020725](./pictures/image-20250710185020725.png) 4. 编译生成 ![image-20250710185213899](./pictures/image-20250710185213899.png) ## 静态库的调用 1. 配置静态库的路径 点击`Options`>`Linker `选择静态库的路径 ![image-20250710185351540](./pictures/image-20250710185351540.png) 2. 编写代码验证 ![image-20250710185636976](./pictures/image-20250710185636976.png) ## 工程调试 ### 断点 #### 设置断点,删除断点 在侧边栏直接点一下出现红点即代表添加断点成功,再点一点即可取消断点 ![image-20250710093412062](./pictures/image-20250710093412062.png) #### 禁用断点,启用断点 左键断点选择`Enable/disable Breakpoint` ![image-20250710093743862](./pictures/image-20250710093743862.png) #### 条件断点 右键断点选中`Edit Breakpoint` ![image-20250710094113043](./pictures/image-20250710094113043.png) 设置i == 5触发断点 ![image-20250710094231504](./pictures/image-20250710094231504.png) 当i == 5时命中断点 ![image-20250710094730465](./pictures/image-20250710094730465.png) ### 监控信息 点击`View`>`Watch` ![image-20250710094911134](./pictures/image-20250710094911134.png) ### 寄存器信息 点击`View`>`Register` ![image-20250710095007025](./pictures/image-20250710095007025.png) ### 内存信息 点击`View`>`Memory` ![image-20250710095042138](./pictures/image-20250710095042138.png) ### 栈信息 点击`View`>`Stack` ![image-20250710095309962](./pictures/image-20250710095309962.png) ### 汇编信息 点击`View`>`Disassembly` ![image-20250710095421681](./pictures/image-20250710095421681.png) ### 调用堆栈信息 点击`View`>`Call Stack` ![image-20250710095527566](./pictures/image-20250710095527566.png) ![image-20250710095633035](./pictures/image-20250710095633035.png) ### 单步调试 #### 逐过程 ![image-20250710095744008](./pictures/image-20250710095744008.png) #### 逐语句 ![image-20250710095806305](./pictures/image-20250710095806305.png) #### 复位 ![image-20250710095819062](./pictures/image-20250710095819062.png) #### 跳出 ![image-20250710095832140](./pictures/image-20250710095832140.png)