delay()
void delay(uint32_t ms)
Performs a delay for the period specified by ms
.
Time measurement is done using the TickTimer count. When a long delay is specified, the CPU clock is reduced during the polling process.
Every approximately 5 ms after calling delay()
, the internal watchdog process of the TWELITE microcontroller is executed.
※ For example, in the case of while(1) delay(1);
, the delay()
function does not exceed 5 ms, so the watchdog process is not invoked, resulting in a reset after a certain period.
Within the setup()
and wakeup()
functions, since the TickTimer is not yet running, delays are implemented using a while-loop. In this case, the discrepancy from the specified value may be significant. The loop counter is calibrated for 32 MHz. If the CPU clock is altered within these functions, errors proportional to that clock change will occur.
If a short delay such as 1 or 2 ms is specified as a parameter, the error may be relatively large.