关于SysTick_Config的疑问
代码如下:
void SysTick_Init(u32 count)
{
if(SysTick_Config(SystemCoreClock / count))
{
while(1);
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
SysTick_Config的作用是什么??我找了很久都找不到它的定义,函数手册找不到,软件中找定义也找不到。
我该如何找。
一般IDE的右键菜单里都有“Goto Definition”,可以通过这个找到原始定义。
低版本的Keil需要编译一次才会生成函数/变量间关联信息(Broswe Information)。
或者直接在工程里用全文搜索,也能找出来。
该函数实际是CMSIS中实现,位于core_cm0/3/4.h中,主要是配置Cortex-M内建的SysTick Timer。
SysTick Timer的具体用法请参见Cortex M0或M3/4权威指南中的Operating System Support Features中的The SysTick Timer章节。
/**
\brief System Tick Configuration
\details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
Counter is in free running mode to generate periodic interrupts.
\param ticksNumber of ticks between two interrupts.
\return 0Function succeeded.
\return 1Function failed.
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
must contain a vendor-specific implementation of this function.
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
{
return (1UL); /* Reload value impossible */
}
SysTick->LOAD= (uint32_t)(ticks - 1UL); /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
SysTick->CTRL= SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
return (0UL); /* Function successful */
}
Serval 发表于 2016-7-31 20:48
一般IDE的右键菜单里都有“Goto Definition”,可以通过这个找到原始定义。
低版本的Keil需要编译一次才会 ...
我是用keil的,编译过整个工程后,还是找不到。 本帖最后由 sunnydevil 于 2016-8-1 10:25 编辑
野原新之助 发表于 2016-8-1 09:47
楼主browse information勾上了么,如果勾上了编译通过以后还跳转不到定义的话,就和二楼说的一样用全工程搜索一般都能找到 这个SysTick_Config() 函数,它是属于内核层的 Cortex-M3 通用函数,位于 core_cm3.h 文件中。
core_cm3.h中,用来配置TICK的。 STM32的SYSTICK详解
http://www.51hei.com/bbs/dpj-31803-1.html
(出处: 单片机论坛)
希望对你有帮助……:) 野原新之助 发表于 2016-8-1 09:47
我也遇到了这个问题,SysTick_Config是core_cm0.h文件中的,只要调用这个文件的函数都找不到定义,但是可以编译通过。编译后下载到芯片貌似这函数没起作用。我弄了好几天了,keil也重装了,重新更新。什么方法都用了就是不行。你是怎么解决的可以跟我说说吗! SysTick_Config是一个内联函数,定义在core_cm3.h(按内核)文件中,在core_cm3.h文件中代码如下:
static __INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if (ticks > SysTick_LOAD_RELOAD_Msk)return (1); /* Reload value impossible */
SysTick->LOAD= (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);/* set Priority for Cortex-M0 System Interrupts */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL= SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
return (0); /* Function successful */
}
以下说明内容来自:RM0033_STM32F205xx, STM32F207xx, STM32F215xx和STM32F217xx单片机参考手册
8.1.2 SysTick calibration value register
The SysTick calibration value is fixed to 15000, which gives a reference time base of 1 ms
with the SysTick clock set to 15 MHz (max HCLK/8).
简单的说,调用SysTick_Config(SystemCoreClock / count)函数,可以开启一个频率为count,也就是周期为1/count的周期性中断,中断函数为SysTick_Handler(void)。SysTick_Handler(void)中断优先级高于所有外设中断优先级。
页:
[1]