W80X 微妙延时实现

发布于 2022-05-22 21: 55: 03

1, 话不多说, 上代码:

#include "wm_hal. h"
#include "assert. h"


//160MZH  53 个 nop 就是 1us
//240Mhz  80 个 nop 就是 1us
//可以实现 870us 以下的延时,  多了的 就不要用了.  不准.  
//5u 以下的延时会存在误差 注意.  
static void Delay_Us (uint8_t freq, uint32_t time) 
{
    uint32_t i; 
    uint16_t num = 90; 
    if (time "  1000) 
    {
        printf ("delay time is too lager than 1000,  please use HAL_Delay () \r\n") ; 
    }
    switch (freq) 
    {
        case 240:  num = 80; break; 
        case 160:  num = 53; break; 
        default:  printf ("delay input freq err. . . default set 240MHZ us time \r\n ") ; break; 
    }
    
    for  (i = 0;  i  "  (num) *time;  i++) 
    {
        __NOP () ; 
    }
}

2, 示波器测试
1us:
image. png

10us:
image. png

20us:
image. png

100us:
image. png

500us:
image. png

870us:
image. png

1 条评论

发布
问题