> For the complete documentation index, see [llms.txt](https://mwx.twelite.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mwx.twelite.info/latest_en/api-reference/funcs/systemfunc/delay.md).

# delay()

Waiting for time by polling.

```cpp
void delay(uint32_t ms)
```

The program waits for a given period of time in `ms`.

The time is measured by the TickTimer count. When waiting for a long period of time, the CPU clock is decreased and polling is performed.

{% hint style="info" %}
Every 5ms after calling `delay()`, TWELITE microcontroller performs internal watchdog processing.

For example, if you execute `while(1) delay(1);`, the watchdog processing is not performed because 5ms does not elapse inside `delay()`, and the reset is executed after a certain time.
{% endhint %}

{% hint style="warning" %}
In the `setup(), wakeup()` function, the TickTimer is not yet running, so it waits for a time by a while loop. In this case, the error with the specified value will be large. This loop counter is adjusted to 32Mhz. If the CPU clock is changed in these functions, the error will be proportional to the clock.

If you specify a short time, such as 1 or 2 as a parameter, the error may be large.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mwx.twelite.info/latest_en/api-reference/funcs/systemfunc/delay.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
