Stephane Bouchard wrote:
> 
> Hi,
> 
> I read the code of the sound.c example (by Michael Barabanov, 1997,
> [EMAIL PROTECTED]) and be interest to know a the following thing. This is
> not directly a rtlinux question but can help to produce super-fast periodic
> interrupt driven routine.
> 
> The 8254 Timer on a PC is driven by a base time. This base time, on the
> define of the file mc146818rtc.h can be set with one of the three time bases :
> 
> /* divider control: refclock values 4.194 / 1.049 MHz / 32.768 kHz */
> #  define RTC_REF_CLCK_4MHZ     0x00
> #  define RTC_REF_CLCK_1MHZ     0x10
> #  define RTC_REF_CLCK_32KHZ    0x20
> 
> Can I program the time base on my computer or this time base is hardware
> dependant and must stay with the original configuration ?

This is hardware dependent.  A lower frequency has the advantage of
lower power.  The RTC reference clock input is driven by a a quartz
crystal oscillator circuit.  The frequency is fixed by the selection of
the quartz crystal.  The defines simply ensure that the clock frequency
is divided by the correct value to get a correct clock time for your
particular system.  You will notice that each frequency is close to a
power of two (binary).  This is allows a register value to be used to
easily divide down the crystal frequency to one second increments.

The 8254 Timers (counters 1,2,3) do not use the same clock.  For
example, the Intel 82371sb's compatible 8254 Timers use a 14.31818 MHz
external input that is internally divided down to 1.193317 MHz for a
period of 0.838 uSec.  All of the counters run off the same external
clock input.  Software can only decide on what the hardware multiplies
the 0.838 uSec period by when programming the 8254 Timers.  Since a
period of a wave is equal to half of the frequency, when ever a 0.838
period passes the 82371 will decrement by two the value written into
counter 0.  Every time the counter reaches zero the state of the IRQ0
line is changed, thus generating a square wave equal to the software
programmed value times 0.838 uSec.  This is if mode 3 is selected for
the counter.  No matter what mode is used, the programmed frequency will
always be a multiple of 0.838 uSec for backward compatibility with the
original IBM-PC design.  If you change the counter values it may affect
other hardware and OS functions.    

> 
> If I can program then, can I program the time base independently for each
> counter? I mean then the counter 0 and 1 are set for the int controller and
> the RAM refresh. If I change the configuration and the time bases are
> dependant, the timing cannot be preserved at the same rate for the 18.2Hz
> for the int0 and for RAM refresh. That's right?
> 
> Thanks a lot your answers,
> 
> Stephane Bouchard
> [EMAIL PROTECTED]
> 
> --- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> ----
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/~rtlinux/
--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to