Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtimer_usleep wrong delay time #10073

Closed
leandrolanzieri opened this issue Sep 28, 2018 · 6 comments
Closed

xtimer_usleep wrong delay time #10073

leandrolanzieri opened this issue Sep 28, 2018 · 6 comments
Assignees
Labels
Area: timers Area: timer subsystems Platform: ARM Platform: This PR/issue effects ARM-based platforms State: won't fix State: The issue can not or will not be fixed Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@leandrolanzieri
Copy link
Contributor

Description

While doing some tests on #10011, which uses a 1-wire interface I found out that the xtimer_usleep is introducing an extra delay.

I did some measurements by toggling a GPIO. Here is the value passed to the function vs. the actual delay measured.

Board 1us 5us 10us 50us 100us
nucleo-f410rb 4us 8us 18us 58us 108us
nucleo-l152re 12us 16us 21us 73us 124us

I also confirmed that this is not a delay introduced by the toggle of the pin by adding multiple calls of the xtimer_usleep function and each of them would add this extra time.

Steps to reproduce the issue

Try toggling a GPIO pin and using the xtimer_usleep function to wait:

   while (1) {
        gpio_toggle((GPIO_PIN(PORT_A, 5)));
        xtimer_usleep(10);
    }

Expected results

Should see the pin toggled each 10us.

Actual results

Pin toggles each 21us (on nucleo-152re).

Versions

Installed compiler toolchains
native gcc: gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
arm-none-eabi-gcc: arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
avr-gcc: missing
mips-mti-elf-gcc: missing
msp430-gcc: missing
riscv-none-embed-gcc: missing
clang: clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

Installed compiler libs
arm-none-eabi-newlib: "2.5.0"
mips-mti-elf-newlib: missing
riscv-none-embed-newlib: missing
avr-libc: missing (missing)

Installed development tools
cmake: cmake version 3.10.2
cppcheck: missing
doxygen: 1.8.13
flake8: missing
git: git version 2.17.1
coccinelle: missing

@miri64 miri64 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: timers Area: timer subsystems labels Sep 30, 2018
@Josar
Copy link
Contributor

Josar commented Oct 24, 2018

@leandrolanzieri
The problem is that as it is implemented right now there will always be an offset. As the timer has to match the target before it will be shot. So depending on the Platform there is an constant overhead.
Also for short times when XTIMER_BACKOFF criteria is met the offset varies.

This and other issues can be solve with #8990 (WIP, waiting for other PRs)
which also offers a calibration routine to get best parameters on each platform.

@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@stale stale bot closed this as completed Sep 10, 2019
@aabadie aabadie reopened this Sep 21, 2019
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Sep 21, 2019
@miri64
Copy link
Member

miri64 commented Jul 2, 2020

Is this still an issue with #9530? Is this related to #8251 maybe?

@haukepetersen
Copy link
Contributor

Seems to me this issue is still present and still annoying...

I also just verified that the same seems to be true when using ztimer: #14931

@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 22, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@maribu
Copy link
Member

maribu commented Sep 16, 2022

With xtimer on its way out and ztimer being used instead now every, I'd say this is a wontfix.

If anyone disagrees, please reopen.

@maribu maribu closed this as completed Sep 16, 2022
@miri64 miri64 added the State: won't fix State: The issue can not or will not be fixed label Sep 19, 2022
@miri64
Copy link
Member

miri64 commented Sep 19, 2022

Are we sure this isn't an issue with ztimer_sleep(ZTIMER_USEC) as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: timers Area: timer subsystems Platform: ARM Platform: This PR/issue effects ARM-based platforms State: won't fix State: The issue can not or will not be fixed Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

8 participants