Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The timer...

3 views
Skip to first unread message

Shawn Ramsey

unread,
May 27, 1998, 3:00:00 AM5/27/98
to

I am wondering about the "correct" way of using the PIT for PWM sound
generation (via the PC speaker) under Minix. On single-tasking
operating systems (like DOS) it's trivial to just hook the clock
interrupt and reprogram the timer to whatever rate you need, but under
UNIX-like operating systems (and indeed probably under Windows too, I
don't know and I don't care) doing this will interfere with the kernel's
scheduler and time-keeping functions. Now, the PWM sound-generator I'm
writing is a kernel task, does anyone know a "standard" (elegant) way
of providing it with acurate timing?

Thanks for your attention,
Dave

Matthew Kirkwood

unread,
May 27, 1998, 3:00:00 AM5/27/98
to

Consider using the periodic interrupts feature of the RTC controller.

Matthew.


Kees J Bot

unread,
May 27, 1998, 3:00:00 AM5/27/98
to

In article <Pine.LNX.3.95.980527...@ferret.lmh.ox.ac.uk>,

An example of this may be the kernel profile code of Minix-vmd,
<http://Minix-vmd.cs.vu.nl/current/src/sys/kernel/ibm/profile.c>.

I also pulled this out of Ralf Brown's interrupt list, file CMOS.LST:

----------R0A--------------------------------
CMOS 0Ah - RTC - STATUS REGISTER A (read/write) (usu 26h)

Bitfields for Real-Time Clock status register A:
Bit(s) Description (Table C001)
7 =1 time update cycle in progress, data ouputs undefined
(bit 7 is read only)
6-4 22 stage divider
010 = 32768 Hz time base (default)
3-0 rate selection bits for interrupt
0000 none
0011 122 microseconds (minimum)
1111 500 milliseconds
0110 976.562 microseconds (default 1024 Hz)
SeeAlso: #C002,#C003,#C004
----------R0B--------------------------------
CMOS 0Bh - RTC - STATUS REGISTER B (read/write)

Bitfields for Real-Time Clock status register B:
Bit(s) Description (Table C002)
7 enable cycle update
6 enable periodic interrupt
5 enable alarm interrupt
4 enable update-ended interrupt
3 enable square wave output
2 Data Mode - 0: BCD, 1: Binary
1 24/12 hour selection - 1 enables 24 hour mode
0 Daylight Savings Enable - 1 enables
SeeAlso: #C001,#C003,#C004

Will Rose

unread,
May 27, 1998, 3:00:00 AM5/27/98
to

Shawn Ramsey (ro...@luke.cpl.net) wrote:
: I am wondering about the "correct" way of using the PIT for PWM sound
: generation (via the PC speaker) under Minix. On single-tasking
: operating systems (like DOS) it's trivial to just hook the clock
: interrupt and reprogram the timer to whatever rate you need, but under
: UNIX-like operating systems (and indeed probably under Windows too, I
: don't know and I don't care) doing this will interfere with the kernel's
: scheduler and time-keeping functions. Now, the PWM sound-generator I'm
: writing is a kernel task, does anyone know a "standard" (elegant) way
: of providing it with acurate timing?

I thought there was a spare channel on the PIT? In fact, the clock task
has a couple of millisecond-related routines which the kernel and tasks
can use, and these might well be enough for you.

If not, you're going to have to do something with the clock task. Roughly,
opening the sound device is going to have to tell the clock to reprogram
the timer, and closing the sound device is going to have to tell the clock
it's done. Then the clock can chose when to mess with the PIT, which is
one part of the problem solved.

The other part is the problem of dealing with what is in effect a real-time
data stream; I think that standard Minix messages will be too slow for this.
The data can be buffered into the device without problems, but needs to
leave the driver at fairly accurate intervals timed by the clock. If the
clocks' millisecond routines won't work, then I think you'll need some
sort of separate timer.


Will
c...@crash.cts.com


Shawn Ramsey

unread,
May 27, 1998, 3:00:00 AM5/27/98
to

Will Rose (c...@cts.com) wrote:

: I thought there was a spare channel on the PIT? In fact, the clock task


: has a couple of millisecond-related routines which the kernel and tasks
: can use, and these might well be enough for you.

<snip>

The problem isn't finding a spare channel to do PWM with, you're kinda
forced to use channel 2 since it's the only one strobed to the speaker.
The problem is that the PIT only generates IRQ 8 (INT 0) and the kernel
clock task has this hooked for timekeeping and scheduler functions. So
if we reprogram the PIT and set it to interrupt on timer count, the
clock task will get the interrupt and this will screw everything up.
I like the idea of using the RTC, but I was hoping to maintain
compatibility with PC/XT systems (these don't have RTC's). Modifying
the clock task sounds like a good bet.

Thanks again,
Dave

0 new messages