Skip to content

Please consider replacing delayMicroseconds() with delay() #11

Closed
@MedadRufus

Description

@MedadRufus

Subject of the issue

On the ESP32, the delayMicroseconds() function is a busy-wait. This is a problem with using Free-RTOS on the ESP32, as it holds up the processor, preventing it from doing anything else. On the other hand, the delay() implementation is non-blocking. This works because the RTOS tick frequency is once every millisecond(1 kHz).

In this library, there are 2 instances of delayMicroseconds(), both for 500 microseconds. I recommend making it 1 millisecond delay with the delay() function instead. Both are delays to wait before checking if bytes are available from u-blox GPS. I don't think there will be any issue waiting for a little bit longer before checking again.

The two locations of these delays are here:


Your workbench

  • What development board or microcontroller are you using?
    Custom dev board integrating ESP32 and U-blox MAX M8Q, connected over UART bus.
  • What version of hardware or breakout board are you using?
    ESP32 + U-blox MAX M8Q
  • How is the breakout board wired to your microcontroller?
    UART connection
  • How is everything being powered?
    3.3V VCC powered via USB and regulated.
  • Are there any additional details that may help us help you?
    I am using FreeRTOS with the ESP32. I use the CallbackExample1_NAV_PVT.ino implementation in the Examples folder. Link

Steps to reproduce

Create an RTOS thread to run the code on CallbackExample1_NAV_PVT.ino

Expected behavior

It should be able to poll the GPS, but return back to doing other tasks while waiting for a response from GPS.

Actual behavior

It is spending a long time waiting for the GPS to respond, holding up the processor from doing other things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions