//系统时钟SysTick 即滴答定时器
/*第一个明显正常
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000))while (1);//内核时钟
volatile uint32_t msTicks;
void SysTick_Handler(void)
{
msTicks++;
}
void Delay(uint32_t dlyTicks)
{
uint32_t curTicks;
curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks)
}
*/
/*这个明显快了
unsigned long usDelay;
unsigned long msDelay;
void Systick_Delay_Init(void)
{
SystemCoreClockUpdate();
usDelay = SystemCoreClock / 1000000;
msDelay = SystemCoreClock / 1000;
SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk;
SysTick->CTRL &= ~(SysTick_CTRL_COUNTFLAG_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk);
}
void Systick_Delay_Cycle(unsigned long ulCycle)
{
SysTick->LOAD = ulCycle;
SysTick->VAL = 0;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
while(!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk))WDOG_Feed();
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
void Systick_Delay_uS(unsigned long uluS)
{
uluS = usDelay * uluS;
SysTick->LOAD = uluS;
SysTick->VAL = 0;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
while(!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk))WDOG_Feed();
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
void Systick_Delay_mS(unsigned long ulmS)
{
ulmS = msDelay * ulmS;
SysTick->LOAD = ulmS;
SysTick->VAL = 0;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
while(!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk))WDOG_Feed();
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
*/ |