Audio / Sound

Overview

Single-channel square-wave with adjustable pulse-width.

3 Levels of volume: 0%, 50%, 100%

 Register 0x71, Bit 0 to 1
 0 = 0% (Silence)
 1 = 50%
 2 = 50%
 3 = 100% (Full volume)
    

Can read back timer values (since sound is assigned to Timer 3).

To hear sound, you must:

Some useful information:

Formulas

Timer3_Frequency = The Timer 3 counting speed in Hz (Check Timers)

Sound_Frequency = The frequency of the note in Hz

Preset_Value = Timer 3 Preset value (to be written in Registers 0x4A and 0x4B)

Sound_Pivot = Timer 3 Pivot value (to be written in Registers 0x4C and 0x4D)

Pulse_Width = Pulse-Width from 0.0 to 1.0 (e.g. 0.0 = 0%, 0.5 = 50% (Square), 1.0 = 100%)

Sound Frequency into Timer 3 Preset

Preset_Value = (Timer3_Frequency / Sound_Frequency) - 1

Timer 3 Preset into Sound Frequency

Sound_Frequency = Timer3_Frequency / (Preset_Value + 1)

Pulse-Width into Sound-Pivot

Sound_Pivot = Preset_Value * Pulse_Width

Sound-Pivot into Pulse-Width

Pulse_Width = Sound_Pivot / Preset_Value