#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
void SysTimerDelay(uint32_t us)
{
if(us==0)
us = 1;
SysTick->LOAD = (us * 6)&0xffffff; /* 12/2 */
SysTick->VAL = (0x00);
SysTick->CTRL = (1<<SysTick_CTRL_ENABLE_Pos);
/* Waiting for down-count to zero */
while((SysTick->CTRL & (1 << 16)) == 0);
}
void SysTimerDelay(uint32_t us)
{
if(us==0)
us = 1;
SysTick->LOAD = (us * 6)&0xffffff; /* 12/2 */
SysTick->VAL = (0x00);
SysTick->CTRL = (1<<SysTick_CTRL_ENABLE_Pos);
/* Waiting for down-count to zero */
while((SysTick->CTRL & (1 << 16)) == 0);
SysTick->CTRL = (0<<SysTick_CTRL_ENABLE_Pos); //关SysTick
}
第一个函数运行没有什么问题,但第二个函数(第二个函数比第一个函数多了红色的语句)运行一小段时间后,会卡在while((SysTick->CTRL & (1 << 16)) == 0);
出不来。这是什么原因呢?
|