News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using the 8254 timer chip

Started by Wilbaius, July 22, 2005, 02:27:20 PM

Previous topic - Next topic

Wilbaius

Hi guys. This is the first time I'm posting anything on this forum...usually when I have a problem in assembly I search the net relentlessly until I find a solution, but on this occasion my search has been fruitless. I need to write bytes to the parallel port address 378h at a rate of 44100 bytes per second, and I have no idea how to do this. I'd thought of using the 8254 timer chip to generate 44100 hardware interrupts per second, then write my own ISR that would send a byte to the parallel port per interrupt request, but I can't find proper material on how to do this. The Kernel Mode Driver tutorial on this site has some info, but it's not well written and generally difficult to understand. Can anyone help? Where can I get info on such stuff? :(

dioxin

If you need to do this with any great accuracy then you'll need to add a little bit of external hardware to the port which buffers the data and passes it on at the required rate.
The the nearest rate that the 8254 timer chip will do is 44191 times per second (0.2% error) but even that will have a lot of jitter on it due to other interrupts taking place.

If you intend to do this in Windows then I'll leave others to help 'cos I don't know how.
If you want to do it in DOS then I can post some code that shows how to use the timer that way.

Paul.

BogdanOntanu

44.000 interupts per seccond would be a big burden on the CPU :D

Usually the paralel port uses a handshaking protocol with the destination device... and not continousely pushing data at a fixed speed...
Are yoy sure that you have the communication protocol fully covered :-?
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Mark Jones

Hi and welcome Wilbaius. That's what I'd suggest: a big buffer in hardware, and "burst" writing blocks of data. :)

Are you thinking of publishing the project on the web? I'd be interested to see how it turns out.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Wilbaius

What I'm actually doing is sending the PCM data contained in a wave file to the parallel port. Connected to the port will be a DAC (Digital to Analog Converter) to convert the data into audible sound. The data rate doesn't have to be super-precise, just somewhere near the 44100 bytes per sec required for 8-bit mono. Hand-shaking protocols too seem unnecessary for this. Mr. Jones, if the project works out, I might just post it on the net. BogdanOntanu, I'm the kind of guy that likes to drive the CPU to the max. I don't intend to use it for any other tasks while sending my PCM data to the parallel port, so I think the machine will handle the many interrupts. Dioxin, I'd appreciate the DOS code, it'd give me ideas. :thumbu

dioxin

Here's some DOS code to do it.
It's written in PowerBASIC but the important parts are inline ASM which you can easily understand.

The only odd bit is that the old timer interrupt vector is copied into the code at this part:
ExitVector:
!jmp far ExitVector


I've just had it running on a K6-400 PC in DOS at the required rate (44,192Hz is as close as you'll get to 44,100) so it can be done. Good luck if you try the same thing in Windows!
Hope it's of some use.

Paul.




[attachment deleted by admin]