Write a delay function with a delay of 1ms for a 51 single-chip microcomputer with a main frequency of 12Mhz

We can use the software timer based on the 51 microcontroller to achieve a 1ms delay, the specific code is as follows: delayms(unsigned int ms) //delay function { unsigned int i; while (ms--) { i=12000; // 12MHz main frequency, 12000 is 1ms while(i--); } }

Guess you like

Origin blog.csdn.net/weixin_35751412/article/details/129536883