[SOLVED] OS_Delay(1) not accurate

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] OS_Delay(1) not accurate

    Hi,

    I am experiencing wrong delay times when using OS_Delay.
    I ask for 1[ms] delay ( OS_Delay(1); ) but the actual delay I receive varies anywhere between 830-950 [us].
    Is this normal behavior for embOS or am I missing something?


    1. Which embOS do you use?
    I use embOS trial for Cortex-M and IAR compiler version 4.40 with IAR workbench 8.20.1 (embOS_CortexM_IAR_V8_Trial_V440).

    2. Which CPU and eval board do you use?
    I use Silicon Labs EFR32FG13P231F512GM48 cpu.

    3. Which start project do you use?
    I downloaded a trial package and used a start project from it (Silicon Labs EFM32_G2XX_DK) and configured it to match my CPU.


    Thanks,
    Lior
  • Hi Lior,

    Thanks for your inquiry. However, this is not an issue, but instead is working as intended. Please refer to the embOS manual on OS_Delay():
    The actual delay (in basic time intervals) will be in the following range: t - 1 ≤ delay ≤ t , depending on when the interrupt for the scheduler occurs.

    To elaborate on this, please imagine the following, examplary scenario:
    - The SysTick is configured to occur at every 1000 timer cycles.
    - At the moment OS_Delay(1) is called by the application, the timer counter already holds 500 cycles.
    So in this situation, 500 cycles have already expired, while another 500 cylces remain before the next occurance of the timer interrupt. Then, OS_Delay(1) will delay the task for 500 timer cycles.
    If, on the other hand, the timer counter holds 200 cycles when OS_Delay(1) is called, then 800 cycles have already expired, and mere 200 cycles remain until the next occurance of the timer interrupt. Then, OS_Delay(1) will delay the task for 200 timer cycles.

    Does this answer your question? Please let me know if I can be of any further help.

    Best regards,
    Martin
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.