
void Delay_Init(void)
{
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);//systick时钟= HCLK/8
fac_us = SystemCoreClock/8000000;
fac_ms = fac_us*1000;
}
void Delay_Us(uint32_t nus)
{
uint32_t temp;
SysTick-》LOAD = nus*fac_us; //时间加载
SysTick-》VAL = 0x00; //清除计数器
SysTick-》CTRL |= SysTick_CTRL_ENABLE_Msk;//打开systick定时器,开始倒计时
do
{
temp = SysTick-》CTRL;
}while((temp&0x01) && !(temp&(1《《16)));
SysTick-》CTRL &= ~SysTick_CTRL_ENABLE_Msk;//关闭systick定时器
SysTick-》VAL = 0x00;//清除计数器
}
void Delay_Ms(uint16_t nms)
{
uint32_t temp;
SysTick-》LOAD = nms*fac_ms;//时间加载
SysTick-》VAL = 0x00; //清除计数器
SysTick-》CTRL |= SysTick_CTRL_ENABLE_Msk;///打开systick定时器,开始倒计时
do
{
temp = SysTick-》CTRL;
}while((temp&0x01) && !(temp&(1《《16)));
SysTick-》CTRL &= ~SysTick_CTRL_ENABLE_Msk;//关闭systick定时器
SysTick-》VAL = 0x00;/清除计数器
}

void Delay_Init(void)
{
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);//systick时钟= HCLK/8
fac_us = SystemCoreClock/8000000;
fac_ms = fac_us*1000;
}
void Delay_Us(uint32_t nus)
{
uint32_t temp;
SysTick-》LOAD = nus*fac_us; //时间加载
SysTick-》VAL = 0x00; //清除计数器
SysTick-》CTRL |= SysTick_CTRL_ENABLE_Msk;//打开systick定时器,开始倒计时
do
{
temp = SysTick-》CTRL;
}while((temp&0x01) && !(temp&(1《《16)));
SysTick-》CTRL &= ~SysTick_CTRL_ENABLE_Msk;//关闭systick定时器
SysTick-》VAL = 0x00;//清除计数器
}
void Delay_Ms(uint16_t nms)
{
uint32_t temp;
SysTick-》LOAD = nms*fac_ms;//时间加载
SysTick-》VAL = 0x00; //清除计数器
SysTick-》CTRL |= SysTick_CTRL_ENABLE_Msk;///打开systick定时器,开始倒计时
do
{
temp = SysTick-》CTRL;
}while((temp&0x01) && !(temp&(1《《16)));
SysTick-》CTRL &= ~SysTick_CTRL_ENABLE_Msk;//关闭systick定时器
SysTick-》VAL = 0x00;/清除计数器
}
举报