28825 Parallax Inc, 28825 Datasheet - Page 6

MINI SOUND PLAYER SOUNDPAL

28825

Manufacturer Part Number
28825
Description
MINI SOUND PLAYER SOUNDPAL
Manufacturer
Parallax Inc
Datasheet

Specifications of 28825

Accessory Type
Sound Player
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
BASIC Stamp®
For Use With
28824 - SERVOPAL SERVO PULSER TIMER
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
extend to the note following without any gaps. It is used most frequently to extend the length of a single
note beyond the longest duration, which is the dotted half. In the following example, the first three notes
of Taps are played with the last being held an extra long time by means of the slur command:
SEROUT iopin, baud, ["=", tmp0, dq+G_0, e+G_0, slur, dh+C_1, dh+C_1, 0, "!"]
Repetition
Many musical sequences and sound effects involve repeated phrases. The SoundPAL provides a repeat
command to accommodate the need for repetition. Each repeat must be followed by a byte indicating
how many times (1 – 254) to repeat the phrase that follows. You can also repeat a phrase ad infinitum
by specifying a repetition of 255. The end of each repeated phrase is indicated by an again command.
This tells the SoundPAL to go back to the repeat until the requisite number of repetitions has been met.
A repeat … again construct with a finite number of repetitions is similar to a FOR … NEXT loop in
PBASIC. With an infinite number of repetitions, it’s more similar to a DO … LOOP construct. Like their
counterparts in PBASIC, repeat … again sequences can be nested. And also like these constructs in
PBASIC, it is necessary that each repeat be matched with exactly one again. Otherwise, the SoundPAL
will behave very erratically.
The following example plays some phrases from “Frere Jacques” using the repeat … again construct:
SEROUT iopin, baud, ["=", repeat, 2, C_0, D_0, E_0, C_0, again]
SEROUT iopin, baud, [repeat, 2, E_0, F_0, h+G_0, again, 0, "!"]
This example also illustrates the fact that that you don’t need to include an entire sequence in one
SEROUT statement. It can be broken up into pieces, with the zero terminator appearing at the end of
the last piece. This is true, so long as the total number of bytes doesn’t exceed the RAM buffer size.
One thing to note here is that the size of the RAM buffer, although stated to be 48 bytes, is elastic,
depending on the complexity of the sequence it contains. The reason for this is that, after the RAM
buffer, there’s a 16-byte stack area. The stack holds temporary data that the SoundPAL needs to keep
track of what it’s doing. It starts at the end of the stack area and builds down toward the RAM buffer.
Repeat … again sequences make use of the stack, as do the SoundPAL’s internal subroutines. Each
time a repeat is encountered, two bytes get “pushed” onto the stack, nudging it two bytes closer to the
end of the RAM buffer. For complex sequences with nested repeats, the stack may actually encroach
upon the RAM buffer, effectively shortening its useable size. If it overwrites part of a sequence that’s
stored there, erratic playback will occur. There is no error checking done by the SoundPAL to prevent this
from occurring, so it is up to the programmer to balance program length and nesting complexity to keep
this from happening.
Playing Pre-programmed Sequences
In additional to individual notes, the SoundPAL can play complete passages stored in its own ROM or
EEPROM memory. The SoundPAL comes pre-programmed with 384 bytes of canned sequences in its
ROM memory. Its 64-byte EEPROM is available for you to store your own sequences. Playing a pre-
programmed sequence is equivalent to calling a subroutine in PBASIC using the GOSUB statement.
When the sequence has finished playing, it returns to the calling sequence, which then resumes from the
calling point. To play a sequence, you have to know its starting address in ROM or EEPROM. Starting
addresses for the SoundPAL’s canned ROM sequences are provided in the SoundPAL PBASIC template.
Each address has a name, corresponding to the particular tune or sound effect that it points to.
EEPROM addresses range from 1 to 63 ($01 to $3F in hex). ROM addresses range from 64 to 255 ($40 to
$FF in hex). The ROM address range may appear to include only 192 bytes. But for ROM memory, these
are word addresses, and each ROM sequence begins on a word (even-byte) boundary. This way a total of
448 bytes (ROM + EEPROM) can be addressed with a one-byte address value.
© Parallax, Inc. • SoundPAL (2007.10.29)
Page 6 of 12

Related parts for 28825