# setup()

Called at the beginning of code execution to write initialization code.

{% hint style="warning" %}
TWENET initialization is also executed after the `setup()` function exits. Do not do anything other than initialization here, since most of the processing is done after TWENET exits.

Items to be noted are listed below.

* Sleep `the_twenet.sleep()` cannot be executed. If you want to sleep immediately after initialization, write the first sleep process in the `begin()` function.
* The `delay()` function is replaced by the processing described below. In this case, the parameter `ms` does not specify milliseconds. \frz

\* Alternative processing for `delay()`.

```cpp
static inline void delay(uint32_t ms) {
		volatile uint32_t ct = ms * 4096;
		while (ct > 0) {
			--ct;
		}
}
```

{% endhint %}


---

# Agent Instructions: 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:

```
GET https://mwx.twelite.info/latest_en/api-reference/sys_callbacks/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
