To jump to another location in the program, place the destination label name in the program where you would
like the jump to occur.
|
Code Example |
Meaning |
|
flash_led |
Jump to label "flash_led:" |
|
sound_effect1.wav motor_on |
Play the audio file sound_effect1.wav and then jump to label "motor_on:" |
This command stops the playing of an audio file that was initiated with the repeat(filename) command.
|
Code Example |
Meaning |
|
stop_r |
Stop audio file playback that was started with the repeat(filename) command. |
This command sets the audio playback rate of the chip. This playback rate should match the sample rate of the audio file, so if the sample rate of the audio file is 8kHz, then the chip should also be set to 8kHz (freq=8k).
The chip supports audio playback rates from 2.5 kHz (freq=2.5k) to 20 kHz (freq=20k).
|
Code Example |
Meaning |
|
freq=12k |
Set the audio sample playback rate to 12 kHz. |
Stop the program and put the chip to sleep (low power mode).
The chip can be woken up by any enabled input.
|
Code Example |
Meaning |
|
end |
Stop the program and put the chip into low power mode. |
Use the tail command to gently step the audio output to zero.
If the data at the end of an audio file does not end near the zero point, it can result in a "pop" sound when the end of the file plays. To alleviate this pop, the tail command can be placed in the program directly after the audio filename. This ramps the audio driver gently down to zero. The tail command is generally not required.
|
Code Example |
Meaning |
|
tail |
Set the audio output driver to zero. |
Rather than use the tail command, it is better practice to make sure that all audio files end at the zero point, including a few samples of silence.
Stop all audio playback.
|
Code Example |
Meaning |
|
stop_v |
Stop all audio playback. |
Set the audio playback volume. Volume level can be set from 0 (minimum) to 7 (maximum).
If the vol command is not used in the program, the volume defaults to the maximum (7).
|
Code Example |
Meaning |
|
vol=5 |
Set the audio playback volume to level 5. |
|
vol=M0 |
Set the audio playback volume to the value stored in M0. |
When setting the volume level equal to a register, the upper most bit in the register will be ignored.
For example, if you set vol=M2 and M2 contains 15 (1111b), then the volume will be set to 7 (0111b).
To play an audio file, insert the filename of the audio file in the program where you would like it to play.
Audio files can be played multiple times in a row by placing n* in front of the filename, where n is 2 to 15.
|
Code Example |
Meaning |
|
sound_effect1.wav |
Play the audio file sound_effect1.wav |
|
3*sound_effect2.wav |
Play the audio file sound_effect2.wav three times in a row |
|
repeat(sound_effect.wav) |
Play and repeat the audio file sound_effect.wav indefinitely. Can be stopped with the stop_r command. |
Audio files must be in .wav format.
Any audio file used in the program must be declared in the [files] section of the program.
See Preparing Your Audio to learn more about editing, processing, and sample rates.
Pause the program for a specified period of time (in seconds).
The delay time has a resolution of .008 seconds (8 mS), and can range from .008 seconds to 15 seconds.
|
Code Example |
Meaning |
|
delay(0.320) |
Pause the program for .320 seconds (320 mS). |
Multiple delays can be placed back to back for extended delay times.
The sound chip provides two types of audio output drivers: Digital-to-Analog Conversion (DAC) and Push-Pull DAC (PPDAC).
DAC generally provides better (and louder) sound, but consumes more power and is a little trickier to work with.
When using DAC output, the speaker should be connected to the SPK1 connector.
|
Code Example |
Meaning |
|
dac |
Set the audio output type to DAC. |
Depending on the Device Name selected in the program, both audio output types may not be available for use.
The sound chip provides two types of audio output drivers: Digital-to-Analog Conversion (DAC) and Push-Pull DAC (PPDAC).
PPDAC is simpler to use, consumes less power, gives good audio quality, and is recommended for almost all applications.
When using PPDAC output, the speaker should be connected to the PWM connector.
|
Code Example |
Meaning |
|
ppdac |
Set the audio output type to PPDAC (PWM). |
Depending on the Device Name selected in the program, both audio output types may not be available for use.