More on 8254: Re: Timer resolution et al : Implementation of Read_timer()

sashti srinivasan svasn_rtems at yahoo.com
Thu Mar 11 11:11:06 UTC 2004


Hello,

> 1. The formula for "total" is probably correct,
> because the 16-bit 
> timers from 8254 are decremented at each clock and
> when they reach zero 
> they are reloaded with the maximum value. 
> Therefore, in order to get 
> the number of 8254 ticks from the beginning of the
> current period, you 
> must subtract the value read from 8254 from the
> maximum value.
     Very sorry for wrong statement.

>     Pay attention to the mode used for initializing
> 8254, in some modes 
> (the "square-wave" modes), each period is composed
> of two half-periods 
> during which the timers are reloaded than
> decremented by two, in such 
> modes it is more complicated to interpret the values
> read from 8254.

  In clock driver, timer0 is initialized as:
    outport_byte(TIMER_MODE,
TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
    outport_byte(TIMER_CNTR0, count >> 0 & 0xff);
    outport_byte(TIMER_CNTR0, count >> 8 & 0xff);

and in timer driver, it is initialized as follows:
timerOn(const rtems_raw_irq_connect_data* used)
{
     outport_byte(TIMER_MODE,
TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
     outport_byte(TIMER_CNTR0, US_TO_TICK(US_PER_ISR)
>> 0 & 0xff);
     outport_byte(TIMER_CNTR0, US_TO_TICK(US_PER_ISR)
>> 8 & 0xff);
      I think this routine in timer driver is never
called or should never be called, because it conflicts
with clock driver.  Is it correct?

> 2. You said that "clicks" is read from timer0.  That
> is not the timer 
> used for interrupts, which is timer1.  The period of
> timer0 (used in 
> ancient PC's for refreshing the dynamic memory)
> would not be related to 
> the BSP_Configuration.
> ........................
>     Check in the code how is updated "Ttimer_val". 
> If it is incremented 
> by tick interrupts, then maybe the "clicks" are
> actually read from 
> timer1, not from timer0, and in that case
> "US_PER_ISR" should be equal 
> to the period of the tick interrupts, as configured.

A fragment from Read_timer is here:
  outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_LATCH);
  inport_byte(TIMER_CNTR0, lsb);
  inport_byte(TIMER_CNTR0, msb);
  clicks = (msb << 8) | lsb;
  total  = (Ttimer_val * US_PER_ISR) + (US_PER_ISR -
TICK_TO_US(clicks));
           It looks that same timer is used in both
clock and timer drivers.  clicks is read from timer0. 
Ttimer_val is incremented in 'timerisr' routine. 
Since we have a clock ISR, this timerisr is not
probably not active.  Does it mean that Ttimer_val is
not incremented at all?  If I am correct, US_PER_ISR
in the above expression should be replaced by
BSP_Configuration.microseconds_per_tick.  And
Ttimer_val should get the value of difference in value
of clock_driver_ticks between Timer_initialize() and
Read_timer().  Please tell me whether I am correct.

With Regards
Srinivasan


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com



More information about the users mailing list