/* Waiting for external XTAL clock ready */
CLK_WaitClockReady(CLK_CLKSTATUS_XTL12M_STB_Msk);
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(PLL_CLOCK);
SYS_LockReg();
}
int main()
{
SYS_Init();
CLK_SetSysTickClockSrc(CLK_CLKSEL0_STCLK_S_HXT_DIV2);
GPIO_SetMode(P3, BIT6, GPIO_PMD_OUTPUT);
while(1)
{
P36 = 0 ;
CLK_SysTickDelay(5000000);//设置5秒的延时,实际大概有0.5秒
P36 = 1 ;
CLK_SysTickDelay(5000000);//设置5秒的延时,实际大概有0.5秒
}
} 作者: Seaber 时间: 2017-2-16 21:56
问题解决;原因如下:作者: Seaber 时间: 2017-2-16 21:57
/**
* @brief 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 ...
* @return None
* @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.
*/
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);
SysTick->CTRL = 0;
} 作者: a_ziliu 时间: 2017-2-23 11:40
只能到2^24,程式有註解 ,最多3秒多。
* @brief 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 ...
* @return None