您的位置 首页 培训

stm32 体系嘀嗒(SysTick) 定时器

系统嘀嗒校准值固定为9000,当系统嘀嗒时钟设定为9MHz(HCLK/8的最大值),产生1ms时间基准。在3.5的库中voidSysTick_CLKSourceConfig(ui…

体系嘀嗒校准值固定为9000,当体系嘀嗒时钟设定为9MHz(HCLK/8的最大值),发生1ms时刻基准。

在3.5 的库中
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
坐落 misc.c 文件中
然后在core_cm3.h 文件中,界说了一个内联函数,完结守时装备,中止敞开,守时器敞开的功用。
/* ################################## SysTick function ############################################ */
#if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
/* SysTick constants */
#define SYSTICK_ENABLE 0 /* Config-Bit to start or stop the SysTick Timer */
#define SYSTICK_TICKINT 1 /* Config-Bit to enable or disable the SysTick interrupt */
#define SYSTICK_CLKSOURCE 2 /* Clocksource has the offset 2 in SysTick Control and Status Register */
#define SYSTICK_MAXCOUNT ((1<<24) -1) /* SysTick MaxCount */
/**
* @brief Initialize and start the SysTick counter and its interrupt.
*
* @param uint32_t ticks is the number of ticks between two interrupts
* @return none
*
* Initialise the system tick timer and its interrupt and start the
* system tick timer / counter in free running mode to generate
* periodical interrupts.
*/
static __INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if (ticks > SYSTICK_MAXCOUNT) return (1); /* Reload value impossible */
SysTick->LOAD = (ticks & SYSTICK_MAXCOUNT) – 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) – 1); /* set Priority for Cortex-M0 System Interrupts */
SysTick->VAL = (0x00); /* Load the SysTick Counter Value */
SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<ICK_ENABLE) | (1<ICK_TICKINT); /* Enable SysTick IRQ and SysTick Timer */
return (0); /* Function successful */
}
#endif
老的库文件的是6个函数
1.void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
下面的这几个的功用都现已被SysTick_Config() 所代替
2.voidSysTick_SetReload(void)
3.voidSysTick_CounterCmd(void)
4.voidSysTick_ITConfig(void)
5.voidSysTick_GetCounter(void)
6.voidSysTick_GetFlagStatus(void)

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/peixun/272867.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部