看到示例里面的SYS_Init()中有几行
- /* Update System Core Clock */
- /* User can use SystemCoreClockUpdate() to calculate PllClock, SystemCoreClock and CycylesPerUs automatically. */
- //SystemCoreClockUpdate();
- PllClock = PLL_CLOCK; // PLL
- SystemCoreClock = PLL_CLOCK / 1; // HCLK
- CyclesPerUs = PLL_CLOCK / 1000000; // For SYS_SysTickDelay()
那么这个是为了延时1us吗?
在clk.h
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] This function execute delay function.
- * @param[in] us Delay time. The Max value is 2^24 / CPU Clock(MHz). Ex:
- * 50MHz => 335544us, 48MHz => 349525us, 28MHz => 699050us ...
- * [url=home.php?mod=space&uid=266161]@return[/url] None
- * [url=home.php?mod=space&uid=1543424]@Details[/url] Use the SysTick to generate the delay time and the UNIT is in us.
- * The SysTick clock source is from HCLK, i.e the same as system core clock.
- * User can use SystemCoreClockUpdate() to calculate CyclesPerUs automatically before using this function.
- */
- __STATIC_INLINE void CLK_SysTickDelay(uint32_t us)
- {
- SysTick->LOAD = us * CyclesPerUs;
- SysTick->VAL = (0x00);
- SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
- /* Waiting for down-count to zero */
- while((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0);
- /* Disable SysTick counter */
- SysTick->CTRL = 0;
- }
看着像。不过看解释的最大延时时间比较短,应该是短的使用这个吧?
|