Microsecond timer


Is it possible to implement 200us sleep within a thread? I tried this ESP32 running P03 (2.2.0):

import hwtimers

Even without any coding I get this message when trying to upload:

[warning] There are 6 missing symbols! This VM does not support the requested features! ['vhalInitHTM', 
'vhalHtmGetFreeTimer', 'vhalInitHTM', 'vhalHtmGetFreeTimer', 'vhalSleepMicros', 'vhalSleepMicros']
[error] Check if the device is virtualized with the last available version-patch of the virtual machine

I was planning to use: hwtimers.sleep_micros(200)

Plan B:
This one: sleep(200,MICROS)
Doesn’t work at all.


Hello Marcel,

microseconds sleep is not available on ESP32, but you could implement a polling sleep by means of the vosTicks() function which returns a pointer to the number of clock ticks.

uint32_t start_ticks = *vosTicks();
while (*vosTicks() - start_ticks < (ticks_for_micros * micros_to_sleep));

But you should make an evaluation of the right ticks_for_micros value