ets_delay_us incorrect in wake stub

timmbo
Posts: 30
Joined: Fri Jan 03, 2020 11:43 am

ets_delay_us incorrect in wake stub

Postby timmbo » Mon Aug 10, 2020 11:58 am

Dear all,

I want to wait a specific time in the wake stub of the ESP32 and I use:

ets_delay_us(200*1000);

for a 200ms delay. Unfortunately I measure 68ms delay.

The function "ets_get_cpu_frequency()" returns 13 in the wake stub, which seems to be wrong? I could not find any information about the default CPU speed in the wake stub, but would assume 40MHz. Is this correct?

How can I wait for a correct amount of time in the wake stub?

Best, Timm

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: ets_delay_us incorrect in wake stub

Postby ESP_igrr » Mon Aug 10, 2020 3:44 pm

Hi Timm,
indeed the "CPU cycles per microsecond" value used by ets_delay_us is not initialized at the time when the deep sleep wake stub runs. You need to include a call to ets_update_cpu_frequency_rom before calling ets_delay_us:

ets_update_cpu_frequency_rom(ets_get_detected_xtal_freq() / 1000000)

timmbo
Posts: 30
Joined: Fri Jan 03, 2020 11:43 am

Re: ets_delay_us incorrect in wake stub

Postby timmbo » Tue Aug 11, 2020 1:28 pm

Hi ESP_igrr,

brilliant! Thanks for your support :-)

Greetings,
Timm

owenjames
Posts: 12
Joined: Fri Sep 02, 2022 6:24 pm

Re: ets_delay_us incorrect in wake stub

Postby owenjames » Fri Apr 28, 2023 12:25 am

I've been trying to do similar on esp-idf v5.0.1. I have this in a component .cpp wake stub:

Code: Select all

ets_update_cpu_frequency_rom(ets_get_xtal_freq() / 1000000);
but build fails with undefined reference to `ets_update_cpu_frequency_rom'

The component has PRIV_REQUIRES esp_rom and I see that esp32.rom.ld includes the line:

Code: Select all

PROVIDE ( ets_update_cpu_frequency_rom = 0x40008550 );  /* Updates g_ticks_per_us on the current CPU only; not on the other core */
How can I resolve this reference?

Who is online

Users browsing this forum: No registered users and 95 guests