This is the mail archive of the ecos-discuss@sourceware.org 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: timer interrupt help


Hi Jeff

Jeffrey Krasky wrote:

> I've been reading about interrupts and how to create/attach them in
> eCos. There is still one piece of information that I am not sure about.
> 
> My goal is to have a timer go off every millisecond, as precise as
> possible. Is there a counter that I can register my ISR with so that
> when the counter reaches a value that's equivalent to 1ms in ticks, it
> will call my ISR? Or do I have to monitor the clock myself? I feel if I
> have to monitor the clock myself I will not achieve 1ms granularity.

The eCos system clock runs off a hardware timer which is typically
initialized to generate interrupts at 100Hz. For many regular
application tasks, you can simply create an eCos alarm and attach it to
the system clock to trigger every 'N' ticks. The associated alarm
function will be called each time the alarm triggers. Ref:

http://ecos.sourceware.org/docs-latest/user-guide/clocks-and-alarm-handlers.html

It would appear that the default eCos system clock frequency is unlikely
to be fast enough for your needs. You can modify the system clock
frequency to a certain extent by adjusting configuration options within
the eCos HAL, but there can be undesirable side effects. Ref:

http://ecos.sourceware.org/docs-latest/ref/kernel-clocks.html

You may prefer to identify another timer in your hardware design and
initialize it to generate interrupts at 1kHz. You can then write an
interrupt handler and attach it to the relevant interrupt vector. The
interrupt handler will be called at 1ms intervals in a manner which is
largely independent of any other activities in your system.

Either way, there is no need to poll a hardware timer.

I hope this helps

John Dallaway

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


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