牛卧堂MCU技术交流
标题:
system tick
[打印本页]
作者:
arm_nuedu
时间:
2017-9-7 10:45
标题:
system tick
CLK_SysTickDelay 函数简介@details 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.
但CyclesPerUs是在HXT情况下,当core clock 不是hxt,一定会自动更新CyclesPerUs的吧???
作者:
a_ziliu
时间:
2017-9-12 10:49
使用者要呼叫 systemcoreclockupdate,去更新CyclesPerUs ,CLK_SysTickDelay 會根據CyclesPerUs 計算
void SystemCoreClockUpdate(void) /* Get Core Clock Frequency */
{
uint32_t u32Freq, u32ClkSrc;
uint32_t u32HclkDiv;
/* Update PLL Clock */
PllClock = CLK_GetPLLClockFreq();
u32ClkSrc = CLK->CLKSEL0 & CLK_CLKSEL0_HCLK_S_Msk;
if(u32ClkSrc != CLK_CLKSEL0_HCLK_S_PLL) {
/* Use the clock sources directly */
u32Freq = gau32ClkSrcTbl[u32ClkSrc];
} else {
/* Use PLL clock */
u32Freq = PllClock;
}
u32HclkDiv = (CLK->CLKDIV & CLK_CLKDIV_HCLK_N_Msk) + 1;
/* Update System Core Clock */
SystemCoreClock = u32Freq / u32HclkDiv;
CyclesPerUs = (SystemCoreClock + 500000) / 1000000;
}
欢迎光临 牛卧堂MCU技术交流 (http://nuvoton-mcu.com/)
Powered by Discuz! X3.2