04.03.2013 Views

RL78/D1A User's Manual: Hardware - Renesas

RL78/D1A User's Manual: Hardware - Renesas

RL78/D1A User's Manual: Hardware - Renesas

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Under development<br />

Preliminary document<br />

Specifications in this document are tentative and subject to change.<br />

<strong>RL78</strong>/<strong>D1A</strong> CHAPTER 17 SOUND GENERATOR<br />

(2) Tone frequency calculation<br />

The tone frequency can be calculated as:<br />

ftone = fSG0CLK / (([SG0FL buffer] + 1) ([SG0FH buffer] + 1) 2)<br />

where:<br />

fSG0CLK : Frequency of Sound Generator’s input clock<br />

fSG0CLK = fCLK / 2<br />

[SG0FL buffer] : Contents of the SG0FL buffer<br />

[SG0FH buffer] : Contents of the SG0FH buffer<br />

Example<br />

If:<br />

– fCLK = 20 MHz<br />

– fSG0CLK = fCLK / 2 = 10 MHz<br />

– [SG0FL buffer] = 255 (00FFH) (this yields a PWM frequency of 39.01 kHz)<br />

– [SG0FH buffer] = 32 (0020H)<br />

then:<br />

– ftone = 592 Hz<br />

Remark Note that the buffer contents can differ from the contents of the associated register until the next compare<br />

match.<br />

17.3.2 Generating the volume information<br />

The sound volume information is generated by comparing the SG0FL counter value with the contents of the SG0PWM<br />

volume buffer. An RS flipflop is set when the counter matches the SG0FL buffer and reset when the counter reaches the<br />

value of the volume buffer SG0PWM.<br />

SG0FL<br />

counter<br />

value<br />

PWM<br />

signal<br />

(RS flipflop<br />

output)<br />

Figure 17-6. PWM Signal Generation<br />

SG0FL buffer value<br />

(when reached, sets the FF)<br />

SG0PWM buffer value<br />

(when reached, resets the FF)<br />

The duty cycle of the PWM signal is determined by the difference between the contents of the SG0FL counter buffer<br />

and the contents of the SG0PWM volume buffer. The larger the difference, the smaller the duty cycle.<br />

The PWM signal is continually high when the value of the volume buffer is higher than the value of the frequency<br />

compare buffer.<br />

Remark To achieve 100 % duty cycle for all PWM frequencies, SG0FL must not be set to a value above 1FEH.<br />

The PWM signal is continually low when the value of the volume buffer is zero—the sound has stopped.<br />

R01UH0317EJ0004 Rev. 0.04 1007<br />

Feb. 22, 2013<br />

t

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!