下面两个版本的Sys
tick_Config函数,第一版的定时没问题,第二版的定时就死掉了!请高手帮分析一下是哪里的故障?谢谢!
第一版:
void SysTick_Config(void)
{
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Disable the SysTick Interrupt */
SysTick_ITConfig(DISABLE);
/* Configure HCLK clock as SysTick clock source */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
/* SysTick interrupt each 1MS with HCLK equal to 36MHz */
/*设置SysTick重装载值, 该参数取值必须在1和0x00FFFFFF之间,向下计数
SysTick重装载值/(72M/8)=定时器中断时间 */
//SysTick_SetReload(9000000);// 1S
SysTick_SetReload(9000);// 1mS
//SysTick_SetReload(7200000);// 100mS
//NVIC_SystemHandlerConfig(SystemHandler_MemoryManage, ENABLE);
NVIC_SystemHandlerPriorityConfig(SystemHandler_SysTick, 1, 0);//初始化
/* Enable the SysTick Interrupt */
SysTick_ITConfig(ENABLE);
SysTick_CounterCmd(SysTick_Counter_Enable);
}
第二版:
static __INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if (ticks > SYSTICK_MAXCOUNT) return (1); /* Reload value impossible */
SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (0<
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 */
}
0