Re: Need to run function every 20ms.



Remember though the thread quantum by default is 100ms, so another thread
can easily lock you out for this peroid of time before its chucked out by
the system if it doesn't yield, so you'll need to change this which will
cause more overhead on the system.

I'd look into moving your code into an ISR and have it fired from a HW
system timer, you'd then get a much more accurate and balanced system.

--
--
GraemeW
Blog - http://ce4all.blogspot.com

"Allan Lunk" <allan _at_ ByteWiseSG _dot_ com> wrote in message
news:eHKhOe0SIHA.1188@xxxxxxxxxxxxxxxxxxxxxxx
Thx Chris
That looks perfect--not sure how I missed it.

"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
news:O5n5II0SIHA.4752@xxxxxxxxxxxxxxxxxxxxxxx
Take a look at the multimedia timer. Set it for a 20ms periodic firing.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


"Allan Lunk" <allan _at_ ByteWiseSG _dot_ com> wrote in message
news:%23q7qS3zSIHA.5524@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I have read numerous posts asking similar questions, but my problem is
slightly different.

I have a function (thread) that needs to run every 20ms. I am reading
some counters and ADCs and up-dating some I/O based what I read. It is
important that I read things as regularly as possible. The function
takes several ms (varies) to complete, depending on what it need to do.
I can't (I think..) use Sleep(20), because this will start the 20 ms
after the function completes--and that time varies.

Is there a way to generate a consistent...something.... that will allow
my thread to sample and update I/O?

BTW. I don't have a timer on board that I can use to generate another
interrupt--this may need to change if I can't come up with another way.

thanks for any suggestions.







.



Relevant Pages

  • Re: Need to run function every 20ms.
    ... Take a look at the multimedia timer. ... Chris Tacke, Embedded MVP ... the function completes--and that time varies. ... thread to sample and update I/O? ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Need to run function every 20ms.
    ... Thx Chris ... Chris Tacke, Embedded MVP ... after the function completes--and that time varies. ... my thread to sample and update I/O? ...
    (microsoft.public.windowsce.embedded.vc)
  • Need to run function every 20ms.
    ... I have read numerous posts asking similar questions, ... completes--and that time varies. ... thread to sample and update I/O? ... BTW. ...
    (microsoft.public.windowsce.embedded.vc)

Loading