Related to system clock rate - VxWorks

This is a discussion on Related to system clock rate - VxWorks ; Hi, I have a question related to system clock. The system clock rate on my board is set to 50 by using the sysClkRateSet(50) function. After this if I call taskDelay(50), my task gets waku up exactly after 1 sec ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Related to system clock rate

  1. Related to system clock rate

    Hi,

    I have a question related to system clock. The system clock
    rate on my board is set to 50 by using the sysClkRateSet(50)
    function.
    After this if I call taskDelay(50), my task gets waku up
    exactly after 1 sec but if I call taskDelay(60 * 50), my task gets
    wakeup few seconds before the 1 minuite:

    o/p of one second delay
    -----------------------------------

    tick value : 50
    Before sleeping : 09/08/2008 14:07:58.313208230
    After sleeping : 09/08/2008 14:07:59.313208230

    Before sleeping : 09/08/2008 14:07:59.313208230
    After sleeping : 09/08/2008 14:08:00.313208230

    Before sleeping : 09/08/2008 14:08:00.313208230
    After sleeping : 09/08/2008 14:08:01.313208230

    o/p of one minute delay
    ----------------------------------

    tick value : 50
    sleeping time : 3000

    Before sleeping : 11/08/2008 17:40:26.332555930
    After sleeping : 11/08/2008 17:41:26.312539720

    Before sleeping : 11/08/2008 17:41:26.312539720
    After sleeping : 11/08/2008 17:42:26.312540670


    Please help why taskDelay(60 * 50) is waking up my task few
    nanoseconds before the actual 1 min. How can I achive the required
    granualarity.

    Thanks,
    Naresh.

  2. Re: Related to system clock rate

    I don't know for certain, but my first thoughts lean towards rounding
    error. Let us assume the h/w timer chip runs at X MHz and a "scaling"
    register. I don't know the correct terminology. The "scaling"
    register counts up to (or down from) number Y. Once it counts up to
    number Y (or down to zero), it generates an interrupt. VxWorks
    intercepts this interrupt and counts it as a tick. When
    sysClkRateRateSet(50) is used, it tries to set the "scaling" register
    to a value such that it will yield as close to 50 ticks per seconds
    (or 50 timer interrupts per second) as possible. However, when this
    number is calculated, there is some rounding error involved as we will
    not quite get 50 ticks per seconds. Over the course of one second,
    the discrepancy is not noticed. However, I suspect that over the
    course of a minute, there is enough accumulation to make the
    difference noticeable.

    I can see two possible options.
    #1. Accept it. Not the answer you are looking for.
    #2. Every so often tinker with sysClkRateSet() to compensate for the
    drift/rounding error.

    I hope this helps.

    Sparky.

    naresh.ganapathine...@gmail.com wrote:
    > Hi,
    >
    > I have a question related to system clock. The system clock
    > rate on my board is set to 50 by using the sysClkRateSet(50)
    > function.
    > After this if I call taskDelay(50), my task gets waku up
    > exactly after 1 sec but if I call taskDelay(60 * 50), my task gets
    > wakeup few seconds before the 1 minuite:
    >
    > o/p of one second delay
    > -----------------------------------
    >
    > tick value : 50
    > Before sleeping : 09/08/2008 14:07:58.313208230
    > After sleeping : 09/08/2008 14:07:59.313208230
    >
    > Before sleeping : 09/08/2008 14:07:59.313208230
    > After sleeping : 09/08/2008 14:08:00.313208230
    >
    > Before sleeping : 09/08/2008 14:08:00.313208230
    > After sleeping : 09/08/2008 14:08:01.313208230
    >
    > o/p of one minute delay
    > ----------------------------------
    >
    > tick value : 50
    > sleeping time : 3000
    >
    > Before sleeping : 11/08/2008 17:40:26.332555930
    > After sleeping : 11/08/2008 17:41:26.312539720
    >
    > Before sleeping : 11/08/2008 17:41:26.312539720
    > After sleeping : 11/08/2008 17:42:26.312540670
    >
    >
    > Please help why taskDelay(60 * 50) is waking up my task few
    > nanoseconds before the actual 1 min. How can I achive the required
    > granualarity.
    >
    > Thanks,
    > Naresh.


  3. Re: Related to system clock rate

    Thanks a lot sparky.
    I got some useful information from your reply.

    I have few doubts regarding the same.

    Is it like 50 is not a correct value for the h/w timer board which I
    am having?
    Can I increase this value to more than 50 say 100 or even 1000 to get
    more accuracy?
    Is there any way to know what is the optimal/best value for my clock
    chip?

    Thanks,
    Naresh.


    On Aug 11, 10:32 pm, peter.mit...@gmail.com wrote:
    > I don't know for certain, but my first thoughts lean towards rounding
    > error. Let us assume the h/w timer chip runs at X MHz and a "scaling"
    > register. I don't know the correct terminology. The "scaling"
    > register counts up to (or down from) number Y. Once it counts up to
    > number Y (or down to zero), it generates an interrupt. VxWorks
    > intercepts this interrupt and counts it as a tick. When
    > sysClkRateRateSet(50) is used, it tries to set the "scaling" register
    > to a value such that it will yield as close to 50 ticks per seconds
    > (or 50 timer interrupts per second) as possible. However, when this
    > number is calculated, there is some rounding error involved as we will
    > not quite get 50 ticks per seconds. Over the course of one second,
    > the discrepancy is not noticed. However, I suspect that over the
    > course of a minute, there is enough accumulation to make the
    > difference noticeable.
    >
    > I can see two possible options.
    > #1. Accept it. Not the answer you are looking for.
    > #2. Every so often tinker with sysClkRateSet() to compensate for the
    > drift/rounding error.
    >
    > I hope this helps.
    >
    > Sparky.
    >
    > naresh.ganapathine...@gmail.com wrote:
    > > Hi,

    >
    > > I have a questionrelatedtosystemclock. Thesystemclock
    > > rate on my board is set to 50 by using the sysClkRateSet(50)
    > > function.
    > > After this if I call taskDelay(50), my task gets waku up
    > > exactly after 1 sec but if I call taskDelay(60 * 50), my task gets
    > > wakeup few seconds before the 1 minuite:

    >
    > > o/p of one second delay
    > > -----------------------------------

    >
    > > tick value : 50
    > > Before sleeping : 09/08/2008 14:07:58.313208230
    > > After sleeping : 09/08/2008 14:07:59.313208230

    >
    > > Before sleeping : 09/08/2008 14:07:59.313208230
    > > After sleeping : 09/08/2008 14:08:00.313208230

    >
    > > Before sleeping : 09/08/2008 14:08:00.313208230
    > > After sleeping : 09/08/2008 14:08:01.313208230

    >
    > > o/p of one minute delay
    > > ----------------------------------

    >
    > > tick value : 50
    > > sleeping time : 3000

    >
    > > Before sleeping : 11/08/2008 17:40:26.332555930
    > > After sleeping : 11/08/2008 17:41:26.312539720

    >
    > > Before sleeping : 11/08/2008 17:41:26.312539720
    > > After sleeping : 11/08/2008 17:42:26.312540670

    >
    > > Please help why taskDelay(60 * 50) is waking up my task few
    > > nanoseconds before the actual 1 min. How can I achive the required
    > > granualarity.

    >
    > > Thanks,
    > > Naresh.



+ Reply to Thread