Motorola MC68VZ328 Manuale Utente

Pagina di 376
PWM Operation
Pulse-Width Modulator 1 and 2
15-3
15.3   
PWM Operation
The pulse-width modulator has three modes of operation—playback, tone, and D/A.
15.3.1  
Playback Mode
In playback mode, the pulse-width modulator uses the data from a sound file to output the resulting audio 
through an external speaker. Although the PWM can reproduce the contents of a sound file, it is necessary 
to use a sampling frequency that is equal to or an even multiple of the one used to originally record the 
sound for the best quality reproduction. 
PWM 1 produces variable-width pulses at a constant frequency. The width of the pulse is proportional to 
the analog voltage of a particular audio sample. At the beginning of a sample period cycle, the PWMO pin 
is set to 1 and the counter begins counting up from 0x00. The sample value is compared on each count of 
the prescaler clock. When the sample and count values match, the PWMO signal is cleared to 0. The 
counter continues counting, and when it overflows from 0xFF to 0x00, another sample period cycle begins. 
The prescaler clock (PCLK) runs 256 times faster than the sampling rate when the PERIOD field of the 
PWMP register is at its maximum value; for 16 kHz sampling, PCLK is 4.096 MHz. For 
human-voice-quality sound, the sampling frequency is either 8 kHz or 16 kHz.
Figure 15-3 illustrates how variable-width pulses affect an audio waveform.
Figure 15-3.   Audio Waveform Generation
Digital sample values can be loaded into the pulse-width modulator either as packed 2-sample 16-bit words 
(big endian format) or as individual 8-bit bytes. A 5-byte FIFO minimizes interrupt overhead. A maskable 
interrupt is generated when there are 1 or 0 bytes in the FIFO, in which case the software can write either 
four 1-byte samples or two 2-sample words into the FIFO. When a 16 kHz sampling frequency is being 
used to play back 8 kHz sampled data while writing 4 bytes at each interrupt, interrupts occur every 
500
µ
s. 
15.3.1.1   
Tone Mode
In tone mode, the pulse-width modulator generates a continuous tone at a single frequency when the PWM 
registers are programmed. The lowest frequency that can be generated is 0.25 Hz. 
15.3.1.2   
D/A Mode
The pulse-width modulator can output a frequency with a different pulse width if a low-pass filter is added 
at the PWMO signal. It can be used to produce a different DC level when programmed using the sample 
fields in the PWMS1 register. When used in this manner, it becomes a D/A converter. 
Pulse-Width Modulation Stream
Filtered Audio