NUC029有多少个系列不同的有不同个系统时钟源
NUC029xAN系列有3个时钟源
NUC029xGE系列的系统时钟有6个时钟源
在Cortex®-M0核中的SysTick的时钟源可以使用CPU时钟或者外部时钟(SYST_CSR[2])。如果使用
外部时钟,SysTick时钟(STCLK)有4个时钟源。时钟源切换使用寄存器STCLK_S(CLKSEL0[5:3]的
设置。 SysTick时钟框图如图
因此对于滴答时钟都是一样的,一共五个选择
我们看官方提供的BSP库函数,如何使用滴答时钟
- void CLK_SetSysTickClockSrc(uint32_t u32ClkSrc);
- void CLK_EnableSysTick(uint32_t u32ClkSrc, uint32_t u32Count);
- void CLK_DisableSysTick(void);
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] Set SysTick clock source
- * @param[in] u32ClkSrc is module clock source. Including:
- * - \ref CLK_CLKSEL0_STCLKSEL_HXT
- * - \ref CLK_CLKSEL0_STCLKSEL_LXT
- * - \ref CLK_CLKSEL0_STCLKSEL_HXT_DIV2
- * - \ref CLK_CLKSEL0_STCLKSEL_HCLK_DIV2
- * - \ref CLK_CLKSEL0_STCLKSEL_HIRC_DIV2
- * [url=home.php?mod=space&uid=266161]@return[/url] None
- * [url=home.php?mod=space&uid=1543424]@Details[/url] This function set SysTick clock source. \n
- * The register write-protection function should be disabled before using this function.
- */
- void CLK_SetSysTickClockSrc(uint32_t u32ClkSrc)
- {
- CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_STCLKSEL_Msk) | u32ClkSrc;
- }
- /**
- * @brief Enable System Tick counter
- * @param[in] u32ClkSrc is System Tick clock source. Including:
- * - \ref CLK_CLKSEL0_STCLKSEL_HXT
- * - \ref CLK_CLKSEL0_STCLKSEL_LXT
- * - \ref CLK_CLKSEL0_STCLKSEL_HXT_DIV2
- * - \ref CLK_CLKSEL0_STCLKSEL_HCLK_DIV2
- * - \ref CLK_CLKSEL0_STCLKSEL_HIRC_DIV2
- * - \ref CLK_CLKSEL0_STCLKSEL_HCLK
- * @param[in] u32Count is System Tick reload value. It could be 0~0xFFFFFF.
- * @return None
- * @details This function set System Tick clock source, reload value, enable System Tick counter and interrupt. \n
- * The register write-protection function should be disabled before using this function.
- */
- void CLK_EnableSysTick(uint32_t u32ClkSrc, uint32_t u32Count)
- {
- /* Set System Tick counter disabled */
- SysTick->CTRL = 0;
- /* Set System Tick clock source */
- if(u32ClkSrc == CLK_CLKSEL0_STCLKSEL_HCLK)
- SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk;
- else
- CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_STCLKSEL_Msk) | u32ClkSrc;
- /* Set System Tick reload value */
- SysTick->LOAD = u32Count;
- /* Clear System Tick current value and counter flag */
- SysTick->VAL = 0;
- /* Set System Tick interrupt enabled and counter enabled */
- SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
- }
- /**
- * @brief Disable System Tick counter
- * @param None
- * @return None
- * @details This function disable System Tick counter.
- */
- void CLK_DisableSysTick(void)
- {
- /* Set System Tick counter disabled */
- SysTick->CTRL = 0;
- }
|