🌐
ESP32 Forum
esp32.com › viewtopic.php
small numbers of µS delays - ESP32 Forum
Company gang here. ets_delay_us works by actively polling a timer until that timer value is larger than a given value. This means it should always wait the given amount of uS.
🌐
Esp32developer
esp32developer.com › programming-in-c-c › delays › delays
Delays – ESP32 Developer
We’ve also found instances where ... if you get weird slowness · The ROM function ets_delay_us() (defined in rom/ets_sys.h) will allow you to busy-wait a specified number of uS....
Discussions

Example doesn't compile due to implicit declaration of functions
[912/920] Building C object ...sp-idf-v5.0.2/components/esp32-camera-2.0.3/target/esp32/ll_cam.c:208:5: error: implicit declaration of function 'ets_delay_us'; did you mean 'esp_rom_delay_us'?... More on github.com
🌐 github.com
8
May 17, 2023
Struggling with programming DS18B20 in ESP-IDF
Your bus reset doesn't look good. After you remove the 500 us reset, you should wait a short while. Then sample the bus. Then do a longer wait to let the devices remove any presence pulse. The presence pulse is at least 60 us long but can be significantly longer. But you wait a longer while after removing the reset. And then you look for presence. And then instantly starts sending data. The presence pulse has probably already ended when you look for it. Edit: I haven't looked at the max data length for a SPI word on the ESP32, but I normally use SPI hardware for 1-wire. Nice with hardware acceleration and no need to turn off any interrupts or block any task switches. The SPI sends the bit cell with MOSI and also reads back any response with MISO. An extra pin wasted but well worth it. More on reddit.com
🌐 r/esp32
4
0
December 29, 2023
incorrect declaration of ets_delay_us
ets_delay_us is declared in osapi.h as follows: void ets_delay_us(uint16_t us); in fact, its implementation operates on 32-bit argument, not 16-bit. it should be uint32_t. More on github.com
🌐 github.com
1
July 26, 2017
ESP8266 non-os SDK problems
However, I’m getting the following error: lib/PCA9685Lib/PCA9685Lib.cpp: In member function 'uint8_t PCA9685::setSleep(bool)': lib/PCA9685Lib/PCA9685Lib.cpp:39:24: error: 'ets_delay_us' was not declared in this scope os_delay_us(600); ^ *** [.pioenvs/esp12e/lib/PCA9685Lib/PCA9685Lib.o] Error ... More on community.platformio.org
🌐 community.platformio.org
0
0
October 1, 2016
🌐
SourceVu
sourcevu.sysprogs.com › espressif › esp-idf › symbols › ets_delay_us
ets_delay_us() - syntax, references, description - SourceVu
SourceVuESP-IDF Framework and ExamplesESP-IDFets_delay_us() CPU do while loop for some time. In FreeRTOS task, please call FreeRTOS apis. Show: Summary · Declaration · from ets_sys.h:381 · void ets_delay_us(uint32_t us); Argument · us · None · from examples ·
🌐
GitHub
github.com › espressif › esp32-camera › issues › 534
Example doesn't compile due to implicit declaration of functions · Issue #534 · espressif/esp32-camera
May 17, 2023 - [912/920] Building C object ...sp-idf-v5.0.2/components/esp32-camera-2.0.3/target/esp32/ll_cam.c:208:5: error: implicit declaration of function 'ets_delay_us'; did you mean 'esp_rom_delay_us'?...
Author   espressif
🌐
Reddit
reddit.com › r/esp32 › struggling with programming ds18b20 in esp-idf
r/esp32 on Reddit: Struggling with programming DS18B20 in ESP-IDF
December 29, 2023 -

Hello,

I'm trying to make a program to get temperature readings from a DS18B20. I can get the initialization working but can't get the read ROM (maybe SKIP ROM and CONVERT T as well) command to work. I get 111111111111 as my output in binary when I run my code. I've looked at sample code on GitHub and other than not using hex to send commands, not having code for all commands and not having capabilities for multiple sensors, I'm not sure where I'm going wrong. I also don't have a very in-depth knowledge of programming MCUs and using C, so I'm sure I'm missing something.

I'm hoping someone could help me identify my mistake(s).

#include <stdio.h>
#include "rom/gpio.h"
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "esp_timer.h"

#define DATA_BUS 4

void writeOne();
void writeZero();
int readBus();

void app_main(void)
{
    gpio_pad_select_gpio(DATA_BUS);

    while(1)
    {
        int binary[12] = {};

        //INITIALIZATION

        gpio_set_direction(DATA_BUS, GPIO_MODE_OUTPUT);
        portDISABLE_INTERRUPTS();
        gpio_set_level(DATA_BUS, 0);
        ets_delay_us(500);
        gpio_set_direction(DATA_BUS, GPIO_MODE_INPUT);
        ets_delay_us(75);
        portENABLE_INTERRUPTS();
        if(gpio_get_level(DATA_BUS) == 0)
        {
            //SKIP ROM send CCh = 1100 1100b

            writeZero();
            writeZero();
            writeOne();
            writeOne();

            writeZero();
            writeZero();
            writeOne();
            writeOne();

            //CONVERT T send 44h = 0100 0100b

            writeZero();
            writeZero();
            writeOne();
            writeZero();

            writeZero();
            writeZero();
            writeOne();
            writeZero();

            vTaskDelay(1000 / portTICK_PERIOD_MS);

            //INITIALIZATION

            gpio_set_direction(DATA_BUS, GPIO_MODE_OUTPUT);
            portDISABLE_INTERRUPTS();
            gpio_set_level(DATA_BUS, 0);
            ets_delay_us(500);
            gpio_set_direction(DATA_BUS, GPIO_MODE_INPUT);
            ets_delay_us(75);
            portENABLE_INTERRUPTS();
            if(gpio_get_level(DATA_BUS) == 0)
            {
                //SKIP ROM send CCh = 1100 1100b

                writeZero();
                writeZero();
                writeOne();
                writeOne();

                writeZero();
                writeZero();
                writeOne();
                writeOne();

                //READ SCRATCHPAD send BEh == 1011 1110b

                writeZero();
                writeOne();
                writeOne();
                writeOne();

                writeOne();
                writeOne();
                writeZero();
                writeOne();

                for(int i = 0; i < 12; i++)
                {
                    binary[i] = readBus();
                }
                gpio_set_direction(DATA_BUS, GPIO_MODE_OUTPUT);
                portDISABLE_INTERRUPTS();
                gpio_set_level(DATA_BUS, 0);
                ets_delay_us(500);
                gpio_set_direction(DATA_BUS, GPIO_MODE_INPUT);
                ets_delay_us(75);
                portENABLE_INTERRUPTS();
                printf("\n");

                vTaskDelay(1000 / portTICK_PERIOD_MS);
            }
            else
            {
                printf("Error2\n");
            }
        }
        else
        {
            printf("Error1\n");
        }
    }
}

//first: initialize
//second: skip rom
//third: convert t
//fourth: initialize
//fifth: skip rom
//sixth: read scratchpad

void writeOne()
{
    gpio_set_direction(DATA_BUS, GPIO_MODE_OUTPUT);
    portDISABLE_INTERRUPTS();
    gpio_set_level(DATA_BUS, 0);
    ets_delay_us(10);
    gpio_set_direction(DATA_BUS, GPIO_MODE_INPUT);
    ets_delay_us(80);
    ets_delay_us(10);
    portENABLE_INTERRUPTS();
}

void writeZero()
{
    gpio_set_direction(DATA_BUS, GPIO_MODE_OUTPUT);
    portDISABLE_INTERRUPTS();
    gpio_set_level(DATA_BUS, 0);
    ets_delay_us(80);
    gpio_set_direction(DATA_BUS, GPIO_MODE_INPUT);
    ets_delay_us(10);
    ets_delay_us(10);
    portENABLE_INTERRUPTS();
}

int readBus()
{
    int value;
    gpio_set_direction(DATA_BUS, GPIO_MODE_OUTPUT);
    portDISABLE_INTERRUPTS();  
    gpio_set_level(DATA_BUS, 0);
    ets_delay_us(3);
    gpio_set_direction(DATA_BUS, GPIO_MODE_INPUT);
    ets_delay_us(3);
    value = gpio_get_level(DATA_BUS);
    ets_delay_us(64);
    portENABLE_INTERRUPTS();
    printf("%d\n", value);
    return value;
}

🌐
ESP32 Forum
esp32.com › viewtopic.php
Will ets_delay_us() work on core 1? - ESP32 Forum
September 23, 2021 - I have a task that was using ets_delay_us(), I was pinning this task to core 0 and have now moved the task to core 1. It appears that ets_delay_us() no longer works. esp_timer task is running on core 0. I know that ets_delay_us() is in the ROM, but I expected it to run on the core from which ...
Find elsewhere
🌐
ESP32 Forum
esp32.com › viewtopic.php
ets_delay_us incorrect in wake stub - ESP32 Forum
August 10, 2020 - 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)
🌐
Espressif
docs.espressif.com › projects › esptool › en › latest › esp32c3 › esptool › advanced-commands.html
Advanced Commands - ESP32-C3 - — esptool latest documentation
Due to a limitation in the ROM loader, when using --no-stub any very early serial output from a program may be lost if the program resets or reconfigures the UART. To avoid this problem, a program can be compiled with ets_delay_us(1) as the very first statement after the entry point.
🌐
ESP32 Forum
esp32.com › viewtopic.php
Wait microsecond - ESP32 Forum
The RTOS tick period is (by default) ... any shorter than 1ms. The ROM function ets_delay_us() (defined in rom/ets_sys.h) will allow you to busy-wait for a correct number of microseconds....
🌐
GitHub
github.com › espressif › ESP8266_NONOS_SDK › issues › 31
incorrect declaration of ets_delay_us · Issue #31 · espressif/ESP8266_NONOS_SDK
July 26, 2017 - ets_delay_us is declared in osapi.h as follows: void ets_delay_us(uint16_t us); in fact, its implementation operates on 32-bit argument, not 16-bit. it should be uint32_t.
Author   espressif
🌐
GitHub
github.com › espressif › ESP8266_RTOS_SDK › issues › 680
Make time critical sections (microsecond accurate) possible with WiFi on (GIT8266O-244) · Issue #680 · espressif/ESP8266_RTOS_SDK
August 13, 2019 - uint32_t IRAM_ATTR onewire_read_bit(void) { uint32_t r; uint32_t savedLevel = XTOS_DISABLE_ALL_INTERRUPTS; GPIO_FAST_OUTPUT_ENABLE(ONEWIRE_PIN); GPIO_FAST_SET_0(ONEWIRE_PIN); ets_delay_us(3); GPIO_FAST_OUTPUT_DISABLE(ONEWIRE_PIN); ets_delay_us(10); // Somewhere near here, sometimes we still get 10us extra delay r = GPIO_FAST_GET_LEVEL(ONEWIRE_PIN); XTOS_RESTORE_INTLEVEL(savedLevel); usleep(53); return r; } 👍React with 👍1smadurange ·
Author   espressif
🌐
PlatformIO Community
community.platformio.org › t › esp8266-non-os-sdk-problems › 845
ESP8266 non-os SDK problems - PlatformIO Community
October 1, 2016 - I’m trying to call os_delay_us from the esp8266 sdk. However, I’m getting the following error: lib/PCA9685Lib/PCA9685Lib.cpp: In member function 'uint8_t PCA9685::setSleep(bool)': lib/PCA9685Lib/PCA9685Lib.cpp:39:24: error: 'ets_delay_us' was not declared in this scope os_delay_us(600); ^ *** [.pioenvs/esp12e/lib/PCA9685Lib/PCA9685Lib.o] Error 1 It apparently is finding the header file “osapi.h” fine, because that is there os_delay_us is defined as ets_delay_us.
🌐
GitHub
github.com › pycom › pycom-esp-idf › blob › master › components › esp32 › test › test_delay.c
pycom-esp-idf/components/esp32/test/test_delay.c at master · pycom/pycom-esp-idf
September 16, 2024 - #include "rom/ets_sys.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" #include "test_utils.h" · typedef struct { int delay_us; int method; int result; SemaphoreHandle_t done; } delay_test_arg_t; ·
Author   pycom
🌐
GitHub
github.com › staniond › esp32_puflib › issues › 1
ets_delay_us(...) is not defined in puf_measurement.c · Issue #1 · staniond/esp32_puflib
April 13, 2022 - -o esp-idf/puflib/CMakeFiles/__idf_puflib.dir/puf_measurement.c.obj -c /PATH/TO/PROJECT/components/puflib/puf_measurement.c /PATH/TO/PROJECT/components/puflib/puf_measurement.c: In function 'turn_off_rtc_sram': /PATH/TO/PROJECT/components/puflib/puf_measurement.c:72:5: error: implicit declaration of function 'ets_delay_us'; did you mean 'esp_rom_delay_us'?
Author   staniond
🌐
Reddit
reddit.com › r/rust › esp32 example project
r/rust on Reddit: ESP32 example project
March 7, 2023 -

Hello, I am trying to build this (https://github.com/esp-rs/esp-idf-template) template project for ESP32 but when I try to cargo build this it gets stuck on: “Building [=======================> ] 167/171: esp-idf-sys(build)” for many minutes and then it crashes with:

“error: failed to run custom build command for esp-idf-sys v0.31.12

Caused by: process didn't exit successfully: /[path]/test01/target/debug/build/esp-idf-sys-e68285a66a988f80/build-script-build (exit status: 101)”

I am new to Rust so maybe it’s just a stupid mistake I am making. cargo clean doesn’t fix it. Does anyone have an idea how to fix it?

🌐
GitHub
github.com › pycom › pycom-esp-idf › blob › master › components › esp32 › include › rom › ets_sys.h
pycom-esp-idf/components/esp32/include/rom/ets_sys.h at master · pycom/pycom-esp-idf
* @brief Set the real CPU ticks per us to the ets, so that ets_delay_us will be accurate. * * @note This function only sets the tick rate for the current CPU. It is located in ROM, * so the deep sleep stub can use it even if IRAM is not initialized yet.
Author   pycom
🌐
ESP32 Forum
esp32.com › viewtopic.php
freeRTOS microsecond delay - ESP32 Forum
September 23, 2022 - The complete code : void motor_move() { while(1) { gpio_set_level(EN_PIN, 0); gpio_set_level(DIR_PIN , 0); for(int32_t i =stepper1.curr_pos ; i>= stepper1.pos; i--) { gpio_set_level(STEP_PIN , 0); ets_delay_us(5); gpio_set_level(STEP_PIN , 1); ets_delay_us(5); stepper1.curr_pos = i; printf("current position : %d \n",stepper1.curr_pos); if(stepper1.curr_pos==stepper1.pos) { printf("Reached position : %d \n ",stepper1.curr_pos); gpio_set_level(EN_PIN, 1) } } } } and ı also crate a task in the main using upper function void app_main() { gpio_pad_select_gpio(STEP_PIN); gpio_pad_select_gpio(DIR_PI
🌐
GitHub
github.com › esp-rs › esp-idf-hal › issues › 199
General-Purpose Delay Provider · Issue #199 · esp-rs/esp-idf-hal
December 29, 2022 - struct GeneralPurposeDelay; impl embedded_hal_0_2::blocking::delay::DelayUs<u16> for GeneralPurposeDelay { fn delay_us(&mut self, us: u16) { if us < 10_000 { Ets::delay_us(us as u32); } else { FreeRtos::delay_us(us as u32); } } } impl embedded_hal_0_2::blocking::delay::DelayMs<u16> for GeneralPurposeDelay { fn delay_ms(&mut self, ms: u16) { if ms < 10_000 { Ets::delay_ms(ms as u32); } else { FreeRtos::delay_ms(ms as u32); } } }
Author   esp-rs