int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
if(SysTick_Config(SystemCoreClock / 100))
{
while(1);
}
while(1);
}
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
if(SysTick_Config(SystemCoreClock / 100))
{
while(1);
}
while(1);
}
配置Systick的寄存器
void SystickInit(void)
{
SysTick->CTRL&=0xfffffff8; //设置时钟源 停止计数
SysTick->LOAD=9000000-1; //设置计数值>装载寄存器
SysTick->VAL=0x00; //清空当前计数值
SysTick->CTRL|=0xfffffff9; //启动定时器,未使用中断,使用中断用0xfffb
}
在main函数中使用了
if(SysTick->CTRL&0X10000)
i++;
if(i==3) //可以延时三秒
{
i=0;
GPIOE->ODR=~GPIOE->ODR;
}
重点还在于你去看寄存器
一周热门 更多>