3-4
Digitized Sound I/O Programming
Digitized Sound I/O Transfer Rate
Other than direct mode, all the digitized sound I/O operation modes require the
transfer rate to be set before any transfer is carried out. To set the transfer rate, you
may either program the DSP with the respective transfer rate Time Constant
(supported by all DSP versions), or program the DSP with the actual sampling rate
(only available on DSP version 4.xx). In the former case, a simple conversion has to
be done first.
Time Constant is the sampling rate representation used by the DSP. It is calculated
as follows:
Time Constant = 65536 - (256 000 000/(channels * sampling rate))
The channels parameter is 1 for mono and 2 for stereo.
Only the high byte of the result is used to program the DSP. Refer to the chapter on
"DSP commands" for the commands to set the digitized sound I/O transfer rate.
Direct Mode
Direct mode digitized sound I/O should be used when direct data input from or output
to the DSP is required.
Under direct mode, only mono 8-bit unsigned PCM data transfer is supported. The
data transfer rate of direct mode is controlled by the application program itself.
Usually, the timer interrupt is used to facilitate this implementation. The frequency
of the timer interrupt is reprogrammed so that it interrupts at the number of times
needed for that particular transfer rate. A new timer interrupt service routine is used
to read the in-bound data from or write the out-bound data to the DSP.
There is no minimum sampling rate in this case. The maximum depends on how fast
the timer interrupt can be programmed, and on how fast the interrupt service routine
can service the interrupt.
Refer to the chapter "DSP Commands" for details on using the direct mode digitized
sound I/O commands.