Clock and Hardware Timer usage

Cedric Aubert cedric_aubert at yahoo.fr
Tue Jul 1 12:40:45 UTC 2003


Hi

> 	I am not sure that I understood all you wanted to
say
> correctly. Here is what
> I think you want to do and how I suppose you may do
this...:-)))

It sure with my wunderfull emglish, it should be
difficult :-)

> 	If you do have only one timer in your system, you
may
> modify the timer
> interrupt routine in the way you like. In
particular, you may
> reinitialize
> the timer in the interrupt to give the next
interrupt in 5ms and
> not in 10.

Ok, it's not a problem to have a second timer. It's a
FPGA, but I talk
about RTEMS usage of timer. If I have a second timer,
does my problem is
solve ?

My problem is that all the TOD and Software Timer are
based on the OS
tick( click() )
On each tick RTEMS do

rtems_status_code rtems_clock_tick( void )
{
  _TOD_Tickle_ticks();		<- Will not be need if we read
the timer each time
we need TOD

  _Watchdog_Tickle_ticks();	<- Today don't known what
is it !! :-)

  _Thread_Tickle_timeslice();	<- Only every specific
period

  if ( _Thread_Is_context_switch_necessary() &&
       _Thread_Is_dispatching_enabled() )
    _Thread_Dispatch();

  return RTEMS_SUCCESSFUL;
}

and my problem is to have 1000 IT each second to have
a TOD with a step of
1ms or
to have 1000 IT each second to have Software Timer
(Delay or what you want)
with a step of 1ms.

It's not usefull to pass many time in click IT for
nothing (with my 68000
16Mhz, it will only do this :-)))

So I tried to find a intelligent solution to this. And
I have found one but
not very simple to do.

It's to have variable period of click. Short only if
need, and the less
period is the OS tick (for example 10 or 100 ms for
timeslice).
And to have a good TOD precision is to read the timer
each time we need the
TOD.

In fact you will have a timer queue (example) :

1. USER Delay 3 (5ms) of delay
2. Tick_timeslice (10ms) period
3. USER Delay 2 (60ms) of delay
4. USER Delay 1 (100ms) of delay

So at each rtems_clock_tick( void ) we program the
first timer deadline in
the queue in the hardware timer.
After one rtems_clock_tick( void ) the queue will be
this one :

1. Tick_timeslice (5ms) period
2. USER Delay 2 (55ms) of delay
3. USER Delay 1 (95ms) of delay

After one rtems_clock_tick( void ) the queue will be
this one :

1. Tick_timeslice (10ms) period <<---- This one is
here because timeslice()
reprogram a 10ms delay before recall timeslice
2. USER Delay 2 (50ms) of delay
3. USER Delay 1 (90ms) of delay

Expect I am more clear in my explanation. :-)



> 	To preserve still correct TOD counting you need
simply to
> write some logic
> which will call click() only when really 10ms (or
what you have
> defined) have
> passed.
> 	In the above example call click() on each second
interrupt,
> till you will not
> reinitialize the timer to 10ms interrupts back.
> 	Is this what you are looking for?
>


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com



More information about the users mailing list