




已阅读5页,还剩56页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
,IAR的使用方法,1,Contents,软件安装,新建STM32工程模板,程序下载及调试,两个例子,4,1,2,3,2,1.软件安装,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,3,1.软件安装,IAR版本:V7.1Step1:,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,4,1.软件安装,IAR版本:V7.1Step2:打开安装包等待安装包解压,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,5,1.软件安装,IAR版本:V7.1Step3:选择安装“IAREmbbeddedWorkbench”,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,6,1.软件安装,IAR版本:V7.1Step4:点击“Next”,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,7,1.软件安装,IAR版本:V7.1Step5:选择安装目录,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,8,1.软件安装,IAR版本:V7.1Step6:安装结束后将破解工具复制到安装目录下,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,9,1.软件安装,IAR版本:V7.1Step7:点击“Patch”,显示框中出现一下信息证明破解成功。Filepatched!OK-PATCHINGDONE-,10,2.新建STM32工程模板,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,11,2.新建STM32工程模板,Step1:下载STM32固件库(/),ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,12,2.新建STM32工程模板,Step1:下载STM32固件库(/),ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,13,2.新建STM32工程模板,Step1:下载STM32固件库(/),ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,14,2.新建STM32工程模板,什么是STM32库?在51单片机的程序开发中,我们直接配置51单片机的寄存器,控制芯片的工作方式,如中断,定时器等。配置的时候,我们常常要查阅寄存器表,看用到哪些配置位,为了配置某功能,该置1还是置0。这些都是很琐碎的、机械的工作,因为51单片机的软件相对来说较简单,而且资源很有限,所以可以直接配置寄存器的方式来开发。STM32库是由ST公司针对STM32提供的函数接口,即API(ApplicationProgramInterface),开发者可调用这些函数接口来配置STM32的寄存器,使开发人员得以脱离最底层的寄存器操作,有开发快速,易于阅读,维护成本低等优点。当我们调用库的API的时候可以不用挖空心思去了解库底层的寄存器操作,就像当年我们学习C语言的时候,用prinft()函数时只是学习它的使用格式,并没有去研究它的源码实现,如非必要,可以说是老死不相往来。实际上,库是架设在寄存器与用户驱动层之间的代码,向下处理与寄存器直接相关的配置,向上为用户提供配置寄存器的接口。,15,2.新建STM32工程模板,为什么采用库来开发?对于STM32,因为外设资源丰富,带来的必然是寄存器的数量和复杂度的增加,这时直接配置寄存器方式的缺陷就突显出来了:1)开发速度慢2)程序可读性差这两个缺陷直接影响了开发效率,程序维护成本,交流成本。库开发方式则正好弥补了这两个缺陷。而坚持采用直接配置寄存器的方式开发的程序员,会列举以下原因:1)更直观2)程序运行占用资源少初学STM32的同学,普遍因为第一个原因而选择以直接配置寄存器的方法来学习。认为这种方法直观,能够了解到是配置了哪些寄存器,怎样配置寄存器。事实上,库函数的底层实现恰恰是直接配置寄存器方式的最佳例子,想深入了解芯片是如何工作的话,只要追踪到库的最底层实现就能理解,相信你会为它严谨、优美的实现方式而陶醉。要想修炼C语言,就从ST的库开始吧。,16,2.新建STM32工程模板,库目录、文件简介,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,17,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesCMSIS“core_cm3.c文件”在CoreSupport中的是位于CMSIS标准的核内设备函数层的M3核通用的源文件core_cm3.c和头文件core_cm3.h,它们的作用是为那些采用Cortex-M3核设计SOC的芯片商设计的芯片外设提供一个进入M3内核的接口。这两个文件在其它公司的M3系列芯片也是相同的。至于这些功能是怎样用源码实现的,我们可以不用管它,我们只需把这个文件加进我们的工程文件即可,有兴趣的可以深究。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,18,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesCMSIS“DeviceSupport文件夹”,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,19,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesCMSIS“system_stm32f10 x.c文件”是由ST公司提供的,遵守CMSIS标准。该文件的功能是设置系统时钟和总线时钟,M3比51单片机复杂得多,并不是说我们外部给一个8M的晶振,M3整个系统就以8M为时钟协调整个处理器的工作。我们还要通过M3核的核内寄存器来对8M的时钟进行倍频,分频,或者使用芯片内部的时钟。所有的外设都与时钟的频率有关,所以这个文件的时钟配置是很关键的。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,20,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesCMSIS“stm32f10 x.h文件”所有处理器厂商都会将对内存的操作封装成一个宏,即我们通常说的寄存器,并且把这些实现封装成一个系统文件,包含在相应的开发环境中。这样,我们在开发自己的应用程序的时候只要将这个文件包含进来就可以了,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,21,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesCMSIS“启动文件(startup)”文件名的英文缩写的意义如下:cl:互联型产品,stm32f105/107系列vl:超值型产品,stm32f100系列xl:超高密度(容量)产品,stm32f101/103系列ld:低密度产品,FLASH小于64Kmd:中等密度产品,FLASH=64or128hd:高密度产品,FLASH大于128,22,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesCMSIS“启动文件(startup)”启动文件是任何处理器在上点复位之后最先运行的一段汇编程序。在我们编写的c语言代码运行之前,需要由汇编为c语言的运行建立一个合适的环境,接下来才能运行我们的程序。所以我们也要把启动文件添加进我们的的工程中去。总的来说,启动文件的作用是:1.初始化堆栈指针SP;2.初始化程序计数器指针PC;3.设置堆、栈的大小;4.设置异常向量表的入口地址;5.配置外部SRAM作为数据存储器(这个由用户配置,一般的开发板可没有外部SRAM);6.设置C库的分支入口main(最终用来调用main函数);7.在3.5版的启动文件还调用了在system_stm32f10 x.c文件中的SystemIni()函数配置系统时钟,在旧版本的工程中要用户进入main函数自己调用SystemIni()函数。,23,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesSTM32F10 x_StdPeriph_Driver,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,24,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0LibrariesSTM32F10 x_StdPeriph_Driver,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,25,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0ProjectSTM32F10 x_StdPeriph_Template“stm32f10 x_it.c文件”专门用来编写中断服务函数的,在我们修改前,这个文件已经定义了一些系统异常的接口,其它普通中断服务函数由我们自己添加。但是我们怎么知道这些中断服务函数的接口如何写呢?是不是可以自定义呢?答案当然不是的,这些都有可以在汇编启动文件中找到,具体的大家自个看库的启动文件的源码去吧。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,26,2.新建STM32工程模板,库目录、文件简介STM32F10 x_StdPeriph_Lib_V3.5.0ProjectSTM32F10 x_StdPeriph_Template“stm32f10 x_conf.h文件”这个文件被包含进stm32f10 x.h文件。是用来配置使用了什么外设的头文件,用这个头文件我们可以很方便地增加或删除上面driver目录下的外设驱动函数库。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,27,2.新建STM32工程模板,库目录、文件简介前面向大家简单介绍了各个库文件的作用,库文件是直接包含进工程即可,丝毫不用修改,而有的文件就要我们在使用的时候根据具体的需要进行配置。接下来从整体上把握一下各个文件在库工程中的层次或关系,这些文件对应到CMSIS标准架构上。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,28,2.新建STM32工程模板,Step1:复制库文件,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,29,2.新建STM32工程模板,Step2:在IARV7.1下新建工程,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,30,2.新建STM32工程模板,Step2:在IARV7.1下新建工程,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,31,2.新建STM32工程模板,Step2:在IARV7.1下新建工程,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,32,2.新建STM32工程模板,Step3:向工程中添加库文件,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,33,2.新建STM32工程模板,Step3:向工程中添加库文件,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,34,2.新建STM32工程模板,Step4:配置工程,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,35,2.新建STM32工程模板,Step4:配置工程在GeneralOption选项中,在Target选项栏的Device选项中选择主芯片的类型。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,36,2.新建STM32工程模板,Step4:配置工程在C/C+Compiler选项中,对Preprocessor选项进行设置,在此添加头文件的存储路径以及某些标志符号的宏定义。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,37,2.新建STM32工程模板,Step4:配置工程在Linker选项中,选择Config选项,对链接配置文件进行设置,将stm32f2xx_flash.icf文件拷贝到工程文件夹下,该文件主要负责存储器的映射。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,38,2.新建STM32工程模板,Step4:配置工程调试器的选择,在Debugger选项栏的Setup选项条中,选择J-Link/J-Trace调试工具,同时勾选Runtomain选项,使程序直接运行至主函数启动。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,39,2.新建STM32工程模板,Step4:配置工程在Debugger的Download选项中,需要选择Useflashloader选项,这样才能将程序下载到flash中运行。,ImageinformationinproductImage:Notetocustomers:ThisimagehasbeenlicensedtobeusedwithinthisPowerPointtemplateonly.Youmaynotextracttheimageforanyotheruse.,40,2.新建STM32工程模板,Step4:配置工程选择J-Link选择调试通信和接口。一般选用“USB”和“SWD”模式。,41,3.程序下载及调试,42,3.程序下载及调试,Step1:RebuildAll每当工程新建好或移动到其他目录下时,都需要进行一次RebuildAll。,43,3.程序下载及调试,Step1:RebuildAllMessage窗口errors为0,即库文件包含正确。,44,3.程序下载及调试,Step2:程序RebuildAll、Compile、MakeCompile:只编译当前源文件。(不管文件是否改动,或者设置是否变动)Make:(常用)编译,连接当前工程。(编译只编译有改动文件,或者设置变动的文件,工程窗口文件右边会有个*号)RebuildAll:编译,连接当前工程。(不管文件是否改动,或者设置是否变动)。,45,3.程序下载及调试,Step3:程序下载DownloadandDebug(常用)和DebugwithoutDownloading,46,3.程序下载及调试,在线调试LiveWatch,47,3.程序下载及调试,在线调试LiveWatch只有全局变量才能在LiveWatch中查看!,48,3.程序下载及调试,断点调试,49,4.两个例子,50,4.两个例子,LED闪烁,/*函数名:LED_GPIO_Config*函数功能:配置I/O口:LED-PC15*输入:无*输出:无*作者:St*创建时间:2015-11-21*/#defineON1#defineOFF0voidLED_GPIO_Config(void)GPIO_InitTypeDefGPIO_InitStructure;/*开启GPIOC的外设时钟*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);/*配置PC15*/GPIO_InitStructure.GPIO_Pin=GPIO_Pin_15;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_Init(GPIOC,51,4.两个例子,LED闪烁,/*函数名:CTRL_LED*函数功能:控制LED灯亮灭,ON为亮,OFF为灭*输入:u8LED_Control*输出:无*作者:St*创建时间:2015-11-21*/voidCTRL_LED(u8LED_Control)if(LED_Control=ON)GPIO_ResetBits(GPIOC,GPIO_Pin_15);elseif(LED_Control=OFF)GPIO_SetBits(GPIOC,GPIO_Pin_15);,52,4.两个例子,LED闪烁,/*briefMainprogram.*paramNone*retvalNone*/voidmain(void)SysTick_Init();LED_GPIO_Config();while(1)CTRL_LED(ON);Delay_us(1000000);CTRL_LED(OFF);Delay_us(500000);,53,4.两个例子,串口,/*函数名:UART4_GPIO_Config*函数功能:配置I/O口:PC10-UART4_TX,PC11-UART4_RX*输入:无*输出:无*作者:St*创建时间:2015-11-21*/voidUART4_GPIO_Config(void)GPIO_InitTypeDefGPIO_InitStructure;/*开启GPIOC的外设时钟*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,ENABLE);/*配置PC10*/GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;GPIO_Init(GPIOC,54,4.两个例子,串口,/*函数名:UART4_Config*函数功能:配置USART2波特率:115200数据位:8位停止位:1位无奇偶校验*输入:无*输出:无*作者:St*创建时间:2015-11-21*/voidUART4_Config(void)USART_InitTypeDefUSART_InitStructure;NVIC_InitTypeDefNVIC_InitStructure;/*GPIOConfiguration*/UART4_GPIO_Config();/*使能USART4时钟*/RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4,ENABLE);/*串口复位*/USART_DeInit(UART4);接下页.,55,4.两个例子,串口,接上页./*USART2参数配置*/USART_InitStruc
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年玉溪市江川区人民医院等招聘真题
- 中级财务会计学(下)(山东联盟)225知到智慧树答案
- 中外歌剧鉴赏知到智慧树答案
- 中外音乐鉴赏知到智慧树答案
- 医学心理伦理学考试模拟题(附答案)
- 老年护理模拟习题(附答案)
- 2025东莞企业高级管理人员劳动合同范本
- 2025独家旅游度假广告代理合同范本助力市场拓展
- 突发事件报道规范-洞察及研究
- 2025年房建泥工班组劳务分包及建筑节能材料研发合作合同
- 2025年湖南湘西自治州州直事业单位招聘考试笔试试卷附答案
- 幼儿园安全责任书及后勤管理制度
- 消防车辆事故课件
- 《2型糖尿病中医防治指南(2024版)》解读课件
- 剑阁县普安镇污水处理厂扩容建设项目环评报告
- 商务楼宇管理办法
- 中国兽药典三部 2020年版
- 学校校舍安全排查台账
- DB32T 4252-2021 民用建筑燃气安全规范
- ISO45001职业健康安全管理体系手册和程序文件
- 《区域大地构造学》全套教学课件
评论
0/150
提交评论