W801, Is there any_nop The operation can achieve convenient software delay?

Publish in 2022-05-22 18: 50: 11

Doing simulation I2C when, Software delay is required, Be ignorant of W801 Is there any similar STM32 the_nop Easy software delay for operation

See more

follower
0
Be viewed
2. 5k
Mrzhao
Mrzhao Certified specialist 2022-05-22
An embedded enthusiast. CSDN Home page: https: //blog. csdn. net/qq_37280428? spm=1011. 2415. 3001. 5343

There are nop

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


//160MZH  53 a nop exactly 1us
//240Mhz  80 a nop exactly 1us
//Can be realized 1ms Following delay,  Much more Don't use it.  forbid.  
//5u The following delays are subject to error Look out.  
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 () ; 
    }
}
1 Multiple replies

Write an answer

Please login to post your answer, Click to log in

publish
problem

Share
Friend

Cell phone
browse

Scan code mobile browsing