本帖最后由 dong_abc 于 2014-5-28 19:17 编辑
给你两段代码,微秒级延时,自己改改吧。
初始化:
- // run the timer on 10ms
- SYST_RVR = (unsigned long)(0.01 * BOOT_BUS_CLOCK); // to do add macro to define the initial timeout
- SYST_CSR = (SysTick_CSR_CLKSOURCE_MASK | SysTick_CSR_ENABLE_MASK);
1秒延时:
- if(SYST_CSR & SysTick_CSR_COUNTFLAG_MASK)
- {
- SYST_CVR = 0; // Finish the clear of the SysTick CountFlag
-
- // increment timeout value
- timeout_cnt++;
- if((timeout_cnt > 100)
- {
- timeout_cnt = 0;
- break;
- }
- }
|