> For the complete documentation index, see [llms.txt](https://yingshaoxo.gitbook.io/university-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yingshaoxo.gitbook.io/university-notes/micro-control-system-51-series/delay-function.md).

# The Delay function

轮子就不要重复造了，特别是过时的轮子

So the basic function is :

```c
void delay(unix x) {
    TMOD = 0x01;
    TR0 = 1;
    while(x--) {
        TH0 = 0xfc;
        TL0 = 0x18;
        while(!TF0) {
        };
        TF0 = 0;
    }
    TR0 = 0;
}
```
