Discussion:
Windows CE application. Heartbeat
(too old to reply)
Luis Alvarez
2010-04-01 08:23:01 UTC
Permalink
Hi!

For a specific application I need to set a 50ms timer. With this, every
time 50ms elapsed I will count a Tic.



This 50ms tics are going to keep all the activity synchronized. For example
an execution of a given function is going to be set each 20 Tics.

I have tried some functions to do this but they are not accurate enough. I
need my tic count exactly each 50ms. What I know is I can use the hardware
timer interruption that takes place every 1ms. I would like to use that
interruption on my application.

The problem is I do not know yet how to do it. I know there is an ISR
handling that interruption and this is supposed to set an event to a IST.
Well, instead I want to set event that I can use in one of the threads of my
system. This way my thread will work exactly every 1ms and increase the Tic
count every 50ms.

Anyway, I have not been able to use that interruption. I do not even know if
it is possible.

Can somebody tell me if the way I want to implement an accurate 50ms tic
count is correct?

If it is not correct, Does anybody have an idea of how implement such a thing?

If it is correct, How do I use the hardware timer interruption on my
application?
Luca Calligaris [eMVP]
2010-04-01 09:52:46 UTC
Permalink
the interrupt processing is normally the following: the HW interrupt is
serviced by the ISR which returns a logical interrupt identifier (sysintr)
to the kernel which signals the associated event. a thread (normally called
IST) which is waiting on that event is scheduled to run: this does not mean
that it will run immediately, it depends on its priority, how many threads
of the same priority etc so you're still not guarntee that your thread will
run every 50ms. this is a link to an old article which talks about interrupt
latency (http://msdn.microsoft.com/en-us/library/ms836807.aspx) . in
addition the 1msec timer used by the scheduler can have a different tick if
the OAL implements (as it is recommended) variable tick scheduler
(http://msdn.microsoft.com/en-us/library/ms901811.aspx)
--
Luca Calligaris (MVP-Windows Embedded)
***@eurotech.it.nospam
www.eurotech.it
Post by Luis Alvarez
Hi!
For a specific application I need to set a 50ms timer. With this, every
time 50ms elapsed I will count a Tic.
This 50ms tics are going to keep all the activity synchronized. For example
an execution of a given function is going to be set each 20 Tics.
I have tried some functions to do this but they are not accurate enough. I
need my tic count exactly each 50ms. What I know is I can use the hardware
timer interruption that takes place every 1ms. I would like to use that
interruption on my application.
The problem is I do not know yet how to do it. I know there is an ISR
handling that interruption and this is supposed to set an event to a IST.
Well, instead I want to set event that I can use in one of the threads of my
system. This way my thread will work exactly every 1ms and increase the Tic
count every 50ms.
Anyway, I have not been able to use that interruption. I do not even know if
it is possible.
Can somebody tell me if the way I want to implement an accurate 50ms tic
count is correct?
If it is not correct, Does anybody have an idea of how implement such a thing?
If it is correct, How do I use the hardware timer interruption on my
application?
Paul G. Tobey [eMVP]
2010-04-01 15:21:02 UTC
Permalink
The closest you can get to using the 1ms tick in your application is to block
a thread on a WaitForSingleObject() call, with the time out value set to the
delay you want. If your thread is high-priority, you should get 'fairly'
accurate timing. Of course you have to figure out how much of a time out you
need to set to make your cycle occur at the right timing (if the rest of this
loop takes 3ms to execute, you set the time out for 47ms, not 50, etc.)

One other possibility is to use the multimedia timer to generate an accurate
time base. Set timeSetEvent() in the help.

What is it that you need to do in this application? Things that require
really accurate timing like that typically are NOT APPLICATION OPERATIONS.
For example, if you are supposed to send some serial packet to an external
device every 50ms, I'd say that belongs in a driver, not an application. The
more you tell us about WHAT you need to do, the better the advice you'll get.

Note also that you haven't even told us what version of Windows CE you're
asking about!

Paul T.
Post by Luis Alvarez
Hi!
For a specific application I need to set a 50ms timer. With this, every
time 50ms elapsed I will count a Tic.
This 50ms tics are going to keep all the activity synchronized. For example
an execution of a given function is going to be set each 20 Tics.
I have tried some functions to do this but they are not accurate enough. I
need my tic count exactly each 50ms. What I know is I can use the hardware
timer interruption that takes place every 1ms. I would like to use that
interruption on my application.
The problem is I do not know yet how to do it. I know there is an ISR
handling that interruption and this is supposed to set an event to a IST.
Well, instead I want to set event that I can use in one of the threads of my
system. This way my thread will work exactly every 1ms and increase the Tic
count every 50ms.
Anyway, I have not been able to use that interruption. I do not even know if
it is possible.
Can somebody tell me if the way I want to implement an accurate 50ms tic
count is correct?
If it is not correct, Does anybody have an idea of how implement such a thing?
If it is correct, How do I use the hardware timer interruption on my
application?
Loading...