系统嘀嗒(SysTick)校准值寄存器
1.(SysTick) 系统嘀嗒时钟是由HCLK 分频 出来的。HCLK=SYSCLK=72MHz
/* Select HCLK/8 as SysTick clock source */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
当系统嘀嗒时钟设定为9 兆赫
或是:
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
当系统嘀嗒时钟设定为72 兆赫
2.系统嘀嗒校准值固定到9000,当系统嘀嗒时钟设定为9 兆赫,产生1ms 时基。
/* SysTick interrupt each 9ms with counter clock equal to 1MHz */
SysTick_SetReload(9000);
该参数取值必须在1和0x00FFFFFF之间
3.
使能一下:
/* Enable the SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Enable);
/* Enable the SysTick Interrupt */
SysTick_ITConfig(ENABLE);
这还有另外一种设置方法:
经试验验证可行:
//NVIC_InitTypeDef NVIC_InitStructure;
/* Configure HCLK clock as SysTick clock source */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
/* Configure the SysTick handler priority */
NVIC_SystemHandlerPriorityConfig(SystemHandler_SysTick, 2, 0);
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* SysTick interrupt each 100 Hz with HCLK equal to 72MHz 每1ms发生一次
SysTick中断 */
SysTick_SetReload(72000);
/* Enable the SysTick Interrupt */
SysTick_ITConfig(ENABLE);
/* Enable the SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Enable);
关键是:SysTick_CLKSourceConfig,和SysTick_SetReload
阅读(7847) | 评论(0) | 转发(0) |