STM32 Systick延迟示例

#define FAC_US        4
#define OW_DELAY480US        479//480.05
void ow_delay_480us(void) {//479.958us
        vu32 temp;
        SysTick->LOAD = OW_DELAY480US * FAC_US - 5; //时间加载,Delay12us5=112:26.50khz,Delay12us5=54:39.919KHZ
        SysTick->VAL = 0x00; //清空计数器
        SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; //开始倒数
        do {
                temp = SysTick->CTRL;
        } while (temp & 0x01 && !(temp & (1 << 16))); //等待时间到达
        SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; //关闭计数器
        SysTick->VAL = 0X00; //清空计数器

}

你可能感兴趣的:(STM32 Systick延迟示例)