在实际的项目开发过程中,常常遇到需要得到一段代码的运行时间,通常的方法是用示波器来测量,这篇博文将用SysTick来实现精确测量程序运行的时间。STM32F4的内核定时器SysTick是一个24位的定时器,需要注意最大的测量时间。
1,开发环境
1,固件库:STM32F4xx_DSP_StdPeriph_Lib_V1.8.0
2,编译器:ARMCCV5.06
3,IDE:KeiluVision5
4,操作系统:Windows10专业版
2,程序源码
MeasureTime.h文件
[cpp]viewplaincopy/**
******************************************************************************
*@fileMeasureTime.h
*@authorXinLi
*@versionv1.0
*@date24-October-2017
*@briefMeasureprogramruntimemodule.
******************************************************************************
*@attention
*
*《h2》《center》Copyright©2017XinLi《/center》《/h2》
*
*Thisprogramisfreesoftware:youcanredistributeitand/ormodify
*itunderthetermsoftheGNUGeneralPublicLicenseaspublishedby
*theFreeSoftwareFoundation,eitherversion3oftheLicense,or
*(atyouroption)anylaterversion.
*
*Thisprogramisdistributedinthehopethatitwillbeuseful,
*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof
*MERCHANTABILITYorFI