stm32 系统嘀嗒(SysTick) 定时器 (2)-解决时钟分频问题
{
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<
return (0); /* Function successful */
}
void SysTick_Initial(u16 periodtimer)
{
SysTick_Config(periodtimer);
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); // 分频放在配置后面,不然分频不起效果
}
评论