This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 1ms polling period


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]