public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Eric Doenges <Eric.Doenges@DynaPel.com>
To: eibach@gdsys.de
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] 1ms polling period
Date: Fri, 26 Sep 2003 06:37:00 -0000	[thread overview]
Message-ID: <3F73DEC3.1000801@DynaPel.com> (raw)
In-Reply-To: <DIIE.00000B5E00059C3B@gdproxy2.gdsys.de>

eibach@gdsys.de wrote:

> I have to do some hardware polling every 1-5 ms. 
> What is the best way to do that in ecos?
> Using the system clock there is only a minimum 10ms period available.
 > I wouldn't like modifying the system clock, but is that the only way
 > to do it? Or should I manually use a hardware timer in my controller
 > to generate an interrupt every 1ms? (My basic hardware is the ATMEL 
EB40A.)
> Or is there maybe a completely different way to do this?
> Any ideas you have about this are appreciated.

I would say that depends on a number of things. If the overhead of eCos
system timer interrupts is not much larger than a normal interrupt,
then changing the system clock period is probably the easiest way to go
since you can use all the normal eCos timer functionality. Another
question is the required accuracy of your polling. If you use a 1ms
clock interrupt, your timing will be off by up to +/- 1ms (you can
probably disregard interrupt and thread switch latency in this case).

In a previous application, I had to poll the UART of a 16MHz 68332
periodically with an accuracy of 5 microseconds. The solution was to
request a timer interrupt sufficiently before ("sufficiently before"
was determined empirically by measuring the interrupt and thread
switching latency and adding a large safety factor) the actual polling 
time, and then poll the hardware timer in the highest priority thread
(with interrupts disabled) until the exact time was reached. Pretty
ugly, but it worked. Obviously, such an approach will suck up a lot of
the available processing resources of your CPU, so depending on how much
other work your application needs to do this may not be workable.
-- 
--------------------------------------------------------------------
|     Eric Doenges              |     DynaPel Laboratories GmbH    |
|     Tel: +49 89 962428 23     |     Fraunhoferstrasse 9/2        |
|     Fax: +49 89 962428 90     |     D - 85737 Ismaning, Germany  |
--------------------------------------------------------------------


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

      parent reply	other threads:[~2003-09-26  6:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-26  5:55 eibach
2003-09-26  6:36 ` Eric de Jong
2003-09-26  6:37 ` Eric Doenges [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F73DEC3.1000801@DynaPel.com \
    --to=eric.doenges@dynapel.com \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=eibach@gdsys.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).