• Full Duplex Codecs:
PCM; G.711 (µ-law, A-law); G.722 ADPCM
• Streaming support
• Upto 96 KiB RAM for user code and data
• Unique ID for user code protection
• Quiet power-on and power-off
• I2S interface for external DAC
• Serial control and data interfaces
• Can be used either as a slave co-processor
or as a standalone processor
• UART for debugging purposes
• New functions may be added with soft-
ware and upto 12 GPIO pins
Description
VS1063a is an easy-to-use, versatile encoder,
decoder and codec for a multitude of audio
formats.
VS1063a contains a high-performance, proprietary low-power DSP core VS_DSP4, ROM
memories, 16 KiB instruction RAM and upto
80 KiB data RAM for user applications running simultaneously with any built-in decoder,
serial control and input data interfaces, upto
12 general purpose I/O pins, a UART, as well
as a high-quality variable-sample-rate stereo
DAC and a stereo ADC, followed by an earphone amplifier and a common voltage buffer.
VS1063a can act both as an “MP3 decoder
IC” or “MP3 encoder IC” slave in a system
with a microcontroller, or as a stand-alone circuit that boots from external SPI memory.
Applications
• MP3-recording audio player
• Streaming server and client
• Wireless audio transfer
• Standalone player and recorder
• Internet phones
Version: 0.40, 2011-09-021
PRELIMINARY
Page 2
VS1063a Prog. Guide
Additional Features
• EarSpeaker Spatial Processing
• Bass & treble controls
• Alternatively a 5-channel equalizer
• AD Mixer allows monitoring A/D con-
verter input while listening to stream
• PCM Mixer allows inserting a sidestream
while listening to main stream
• Adjustable Speed Shifter
• Operates with a single 12..13 MHz or
24..26 MHz clock
• Internal PLL clock multiplier
• Low-power operation
• High-quality on-chip stereo DAC with no
phase error between channels
• Zero-cross detection for smooth volume
change
• Stereo earphone driver capable of driving a 30 Ω load
• Separate voltages for analog, digital, I/O
• Lead-free RoHS-compliant package
Further Description
Operating Modes
VS1063a operates in one of two host modes:
as a slave co-processor or as a standalone
processor.
When used as a slave co-processor VS1063a
can operate in three different operation modes:
decoder, encoder or codec mode. In decoder
mode VS1063a receives its input bitstream
through a serial input bus. The input stream
is decoded and passed through an 18-bit digital volume control to an oversampling sigmadelta DAC. Decoding is controlled via a serial
control bus. In addition to the basic decoding, it is possible to add application specific
features, like DSP effects, to the user RAM
memory, or even to load user applications.
In encoder mode VS1063a can reads audio
from its analog inputs, optionally compresses
the data, which can then be read by the host
processor. In codec mode VS1063a offers a
full-duplex audio interface.
When used as a standalone processor the
VS1063a can boot either from SPI EEPROM
or FLASH memory. Alternatively code and
data can be provided by a host controller.
VS1063a is a pin-compatible alternative for
VLSI Solution’s VS1053. It has all the functionality of VS1053 (except MP1 and MIDI
decoding) and many new features, particularly MP3 and Ogg Vorbis recording.
Also full-duplex codec functions for phone applications have been added to VS1063a.
A factory-programmable unique chip ID provides a basis for digital rights management or
unit identification features.
User Code
Users can write their own user interface or
signal processing code for the VS1063a using VSIDE (VLSI Solution’s Integrated Development Environment).
As a default, there are 16 KiB of free code
RAM and about 4 KiB of free data RAM for
user applications. Depending on the application, the data RAM can be expanded to the
full 80 KiB that is available in VS1063a.
Version: 0.40, 2011-09-022
PRELIMINARY
Page 3
VS1063a Prog. Guide
CONTENTS
Contents
VS10631
Table of Contents3
List of Figures4
1 Introduction5
2 Disclaimer5
3 Definitions6
4 Interfacing with VS1063a Using a Microcontroller7
1Decoder data flow of VS1063a with the user plugin stage highlighted . . . . . . .11
Version: 0.40, 2011-09-024
PRELIMINARY
Page 5
VS1063a Prog. Guide
2DISCLAIMER
1Introduction
This is the VS1063a Programmer’s Guide. Its intent is to provide the reader with a sufficient
amount of information to write programs for VS1063a.
Programs can be written either as plugins which function in cooperation with VS1063a’s existing
decoder framework as shown in Chapter 5, or as applications that take over the whole system
as shown in Chapter 6.
Finally, some audio format specific comments are presented in Chapter 7.
Future versions of this document will also discuss ROM functions and VS1063a startup.
2Disclaimer
The VS10xx Programmer’s Guide represents VLSI Solution’s best attempt at giving a VS1063a
programmer as much information as possible to help creating their own plugins and applications. Nevertheless, this guide is still highly preliminary and very much in a state of flux. It will
be made more comprehensive and accurate over time.
VLSI Solution is not responsible for any errors, omissions, or misleading statements in this
document.
This guide is the third part of a three-part entity, consisting of VS1063a Datasheet, VS1063aHardware Guide, and VS1063a Programmer’s Guide. To avoid repetition, it is assumed that
the reader of this guide has already familiarized himself with the other two documents.
Version: 0.40, 2011-09-025
PRELIMINARY
Page 6
VS1063a Prog. Guide
3DEFINITIONS
3Definitions
Application Standalone application that takes over the normal functionality of VS1063a. See
Chapter 6 for details.
ABR Average BitRate. Bitrate of stream may vary locally, but will stay close to a given number
when averaged over a longer time.
B Byte, 8 bits.
b Bit.
CBR Constant BitRate. Bitrate of stream will be the same for each compression block.
Ki “Kibi” = 210= 1024 (IEC 60027-2).
Mi “Mebi” = 220= 1048576 (IEC 60027-2).
Plugin A piece of software that works in tandem with the VS1063a operating system. See
Chapter 5 for details.
SCI Serial Control Interface, an SPI bus for VS1063a control.
SDI Serial Data Interface, an SPI bus for VS1063a bitstream data.
VBR Variable BitRate. Bitrate will vary depending on how difficult the source material is to
encode.
VS_DSP VLSI Solution’s DSP core.
VSIDE VLSI Solution’s Integrated Development Environment.
W Word. In VS_DSP, instruction words are 32-bit and data words are 16-bit wide.
Version: 0.40, 2011-09-026
PRELIMINARY
Page 7
VS1063a Prog. Guide
4INTERFACING WITH VS1063A USING A MICROCONTROLLER
4Interfacing with VS1063a Using a Microcontroller
This chapter explaings how to interface with the VS1063a using SCI and SDI buses, which
both are special cases of the SPI bus. This document will show how to access the buses using
microcontroller software written in C language. For details on bus signals, see the VS1063a
Datasheet Chapter “SPI Buses”.
To be able to do SCI and SDI operations, let’s first define a basic one-byte SPI transfer:
The SCI (SPI) bus is a control and command bus. Every operation consists of four bytes:
instruction, address, and two data bytes. Instruction and address bytes are always offered by
the microcontroller. If instruction is WriteCommand (2), then also data bytes come from the
microcontroller. If instruction is ReadCommand (3), then data bytes come from VS1063a.
Version: 0.40, 2011-09-027
PRELIMINARY
Page 8
VS1063a Prog. Guide
4INTERFACING WITH VS1063A USING A MICROCONTROLLER
4.1.1Example SCI Read / Write Implementation
Using the SpiTransfer() function, here is how to implement register write and read functions:
In the context of VS1063a, a plugin is a piece of software that coexists with the audio decoder
framework of VS1063a.
Plugins may modify decoded audio data or inject new data into the audio path, use free CPU
time. They may have limited control over some interrupts.
Plugins have to take into account that the operating system is running: they cannot use any
memory areas allocated by the system and they should use as little processing power as possible.
VS1063a doesn’t have hardware resource allocation routines in its operating system, so if the
user wants to access VS1063a hardware, he has to make sure to use only such parts of it that
are not already used by the system. An example of this are interrupts: some are used by the
operating system, and some are free to use.
5.1Plugin Memory Maps
This chapter presents free memory maps for plugins. All units are in words.
5.1.1Plugin Instruction Memory Map (32-bit words)
Free instruction memory for plugins
Start AddrLengthDescription
0x500x3B0Full I memory except jump vectors
5.1.2Plugin X Data Memory Map (16-bit words)
Free X data memory for plugins
Start AddrLengthDescription
0x18000x80User area
0x1C800x180Extra area 1
0x1E400x1C0Extra area 2
Version: 0.40, 2011-09-0210
PRELIMINARY
Page 11
VS1063a Prog. Guide
AAC, FLAC
5−channel
Audio
PauseMono
BassUser
control
TrebleSpeed
EarSpeaker
equalizer
ADC
0
SCI_VOL
Bitstream
SDI bus
SCI bus
Mic/Line In
PCM audio
ST_AMPLITUDE=0SB_AMPLITUDE=0
AIADDR != 0
AIADDR=0
EQ5 Enable = 1
ST_AMPL=0 &
SB_AMPL=0 &
EarSpeakerLevel!=0 &
earSpeakerLevel=0
ST_AMPLITUDE!=0SB_AMPLITUDE != 0
adMixerGain or
pcmMixerVol
Bitstream
shifter
FIFO
enhancer
FIFO
SPEEDSHIFTER_ON=0
SPEEDSHIFTER_ON=0&
SPEEDSHIFTER_ON=1
MONO_OUTPUT=1
MONO_OUTPUT=0
PAUSE_ON
PCMMIXER_ON=1&
ADMIXER_ON=1
PCMMISER_ON=0 & ADMIXER_ON=0
ADMIXER_ON=0
To DAC
DAC
SRC
Sidestream
SDM
WAV, MP2/3,
OGG, WMA,
plugin
5.1.3Plugin Y Data Memory Map (16-bit words)
Free Y data memory for plugins
Start AddrLengthDescription
0x18000x80User area
0xFA140x3ECExtra area
5.2Implementing a Plugin to the Decoder Audio Path
A useful case of cooperative programs is plugin user applications.
5WRITING PLUGINS
User plugins may insert themselves in the decoding signal path, as shown in Figure 1. (For
annotations for other blocks in this figure, see the VS1063a Datasheet.)
Plugins also get information on whenever SCI_AICTRL0 through SCI_AICTRL3 have been
accessed (either read from or written to), or whenever the samplerate changes.
Version: 0.40, 2011-09-0211
Figure 1: Decoder data flow of VS1063a with the user plugin stage highlighted
PRELIMINARY
Page 12
VS1063a Prog. Guide
5WRITING PLUGINS
5.2.1Loading and Activating the Plugin
Loading a plugin is initiated by writing a base address to register SCI_WRAMADDR. The program and its data is then loaded by writing data to register SCI_WRAM.
The plugin is activated by writing its start address to register SCI_AIADDR. Whenever a powerdown, hardware reset or software reset has happened, the plugin needs to be reloaded and
restarted. The reason for this is that whenever VS1063a is reset, it will clear all its data areas
so the plugin will not be intact anymore.
Note: SCI_AIADDR will not be cleared when a software reset has been performed, but you still
need to reload and reactivate the plugin.
5.2.2Audio Path Plugin Call Conventions
The C prototype for the user plugin is as follows:
Legal values for
the different cases are handled. All unhandled values for
SymbolValueDescription
APPL_RESET0Reset all values, n is samplerate
APPL_AUDIO1Audio samples offered, n is number of L/R sample pairs
APPL_W02SCI_AICTRL0 has been written to, n is register value
APPL_W13SCI_AICTRL1 has been written to, n is register value
APPL_W24SCI_AICTRL2 has been written to, n is register value
APPL_W35SCI_AICTRL3 has been written to, n is register value
APPL_R06SCI_AICTRL0 has been read from, n is register value
APPL_R17SCI_AICTRL1 has been read from, n is register value
APPL_R28SCI_AICTRL2 has been read from, n is register value
APPL_R39SCI_AICTRL3 has been read from, n is register value
APPL_BITSTREAM10Obsolete, ignore
APPL_OUT_OF_DATA11Stream input buffer has starved
mode
are described in the following table. The user may choose how many of
mode
should returnn.
Note: It is guaranteed that the first call to the user plugin is always with
Note: When
different from the input samplerate. Otherwise, the user function may return 0.
Note: When returning from APPL_AUDIO, the user function should return the number of samples it created in the function. If the number of samples did not change, returning 0 is also
Version: 0.40, 2011-09-0212
mode
= APPL_RESET, the user function should return its output samplerate if it is
mode
= APPL_RESET.
PRELIMINARY
Page 13
VS1063a Prog. Guide
5WRITING PLUGINS
acceptable. If the number of samples did grow, samples must be written to some other location
than what is pointed to by
**d
. This new pointer must be returned in*d.
Note: If
samples in the audio output buffer. Otherwise it is 1. If the function returns non-zero, then 32
empty stereo samples will be inserted into the output audio stream. So, in a typical case it is
convenient to just returnn.
Input data is always interleaved stereo, left channel first.
Volume control is placed after any user plugins. Thus it is generally a better idea to only write
filters that attenuate some frequencies and don’t emphasize any. To compensate for the lower
volume, main volume setting may be turned higher.
5.2.3Simple Example Audio Path Plugin
This very simple plugin attenuates its input signal by a given number of decibels. The user
can give the number of decibels for the left channel in SCI_AICTRL0 and right channel in
SCI_AICTRL1.
autou_int16DbToLin(registeru_int16dB);
mode
== APPL_OUT_OF_DATA, thennis 0 if there still are still at least 64 stereo
The plugin can be disabled by writing 0 to SCI_AIADDR through SCI.
The plugin can also turn itself off. However, in this case writing to SCI_AIADDR is not succifient. The application needs to write NULL to the pointer variable applAddr (ASM convention:
_applAddr). The type for applAddr is shown below:
VSIDE will get a VS1063a audio path plugin example in Q3/2011.
Version: 0.40, 2011-09-0214
PRELIMINARY
Page 15
VS1063a Prog. Guide
5WRITING PLUGINS
5.3Idle Hook Plugin
Whenever VS1063a has spare time, it will first jump to an idle hook, then halt until the next
interrupt is received. The idle hook pointer is located at instruction address 0. Normally the
idle hook pointer contains a jump command to a dummy hook which does nothing. Address 1
contains a “nop” instruction (needed by VS_DSP because it almost always executes the next
instruction after a control transfer instruction).
To take control of the idle hook, first create a function with the following prototype:
voidMyIdleHook(void);
Then, write the assembler command “J _MyIdleHook” to instruction address 0. This is done
with the formula i = 0x28000000 + a × 0x40, where a is the address of MyIdleHook() and i is the
resulting instruction codeword.
Example: MyIdleHook() has been compiled to address 0x50.
Load that plugin into RAM memory of VS1063a.
Then modify the idle hook: In this case d = 0x28000000 + 0x50 × 0x40 = 0x28001400.
Now you can write 0x8000 to register SCI_WRAMADDR to set instruction address 0.
After that write first 0x1400, then 0x2800 to register SCI_WRAM. For more information on how
to use registers SCI_WRAM and SCI_WRAMADDR, see the VS1063a Datasheet.
Alternatively, if changing the vector using VS_DSP code, use the WriteIMem() function (or, if
using assembler, STI).
5.4Interrupt-Driven Plugin
A plugin can take control of one or more of the system interrupts. However, it needs to take
care that it either replaces the existing interrupt with a version that does essentially the same
things required by the system, or that it finishes by jumping to the original interrupt.
Although more often useful when taking control over the whole system, cooperative plugins
may also sometimes take control of one or more interrupts. To see how to do that, and to see
which interrupts are not used by the operating system, see Chapter 6.2.1.
Version: 0.40, 2011-09-0215
PRELIMINARY
Page 16
VS1063a Prog. Guide
6WRITING USER APPLICATIONS THAT TAKE FULL CONTROL OVER VS1063A
6Writing User Applications that Take Full Control over VS1063a
Full control user applications are programs that take over the system, then build their required
signal paths either from scratch, or partly using the ROM routines offered by the VS1063a ROM
firmware.
VS1063a contains such versatile hardware features that it is not possible to exhaustively go
though all the ways that the IC can be used (and misused). Nevertheless, this chapter will
discuss one way of how to take control over the whole chip.
When the user takes full control of the VS1063a he may use most of the memory areas and
hardware. For details of the accessible hardware, read the VS1063a Hardware Guide.
6.1Application Memory Maps
This chapter presents free memory maps for application programs. All units are in words.
0x18000x80User area
0x1C800x180Extra area 1
0x1E400x1C0Extra area 2
0x20800x1F80Extra area 3
Version: 0.40, 2011-09-0216
PRELIMINARY
Page 17
VS1063a Prog. Guide
6WRITING USER APPLICATIONS THAT TAKE FULL CONTROL OVER VS1063A
6.1.3Application Y Data Memory Map (16-bit words)
Free Y data memory for applications
Start AddrLengthDescription
0x10000x800_g_dcthi
0x18000x80User area
0x1C000x2400_mallocAreaY
0xE0000xA64_earSpeaker
0xE0000xA40_speedShift
0xEA640xFB0_heAac
0xFA140x3ECExtra area
0xFE000x200_pcmFifo
1
These two effects use the same memory area. To be able to use this area, neither EarSpeaker
nor SpeedShift should be used.
1
1
6.2Taking Control of VS1063a
There are many ways how to take control of VS1063a. Perhaps the most straightforward way
is to take the User Application approach, as explained in Chapter 5.2.
However, instead of a program that would act as a filter and return, the application would
typically start by disabling all interrupts, then running initializations including changing required
interrupt vectors if any, then activating those interrupts needed by the application.
Note: when the user application is called for the first time (and this is the time when we are
taking control of the whole system), and interrupt level is 1 or 2. Because of this, if you want to
use interrupts, you must not only set correct interrupt vectors and activate your own interrupts
using INT_ENABLE, but you also must write twice to register INT_GLOB_ENA (what value
you write doesn’t matter). For details of interrupt control registers, see the VS1063a Hardware
Guide.
Version: 0.40, 2011-09-0217
PRELIMINARY
Page 18
VS1063a Prog. Guide
6WRITING USER APPLICATIONS THAT TAKE FULL CONTROL OVER VS1063A
6.2.1Taking Control of Interrupts
To take control of interrupts, the user first needs to write interrupt handlers. This cannot be
directly done in the C language: stack store and restore operations as well as interrupt reactivation will need to be done in Assembly language.
After an interrupt routine has been written, the corresponding interrupt vector needs to be
rerouted to the user’s own routine. Interrupt vectors are stored in instruction RAM memory
starting from address 0x20, as shown in the following table:
To replace an interrupt vector, calculate i = 0x2A00000E+a × 0x40, where a is the address of
your own interrupt handler and i is the resulting instruction codeword.
Note: “JMPI” is the only instruction on VS_DSP that doesn’t have delay slot code execution.
Because of this it is also the only VS_DSP instruction that takes two clock cycles to execute
instead of one.
Example: How to take control over the DAC interrupt. First disable the DAC interrupt by clearing
bit 0 of register INT_ENABLE. Do your other initializations. Then calculate your interrupt vector.
E.g. if your own interrupt is at instruction address 0x50, then i =0x2A00000E + 0x50 × 0x40
= 0x2A00140E. Write this value to instruction address 0x20. Then reactivate the interrupt by
setting bit 0 of INT_ENABLE. (Note that disabling and re-enabling the interrupt isn’t necessarily
needed if you don’t care that the old interrupt may occur during your initializations.)
6.3VSIDE and Applications
VSIDE will get a VS1063a full control application example in Q3/2011.
VLSI Solution’s Ogg Vorbis Encoder VSOVE v2.00 is a continuation of the proprietary VS1053b
Ogg Vorbis encoder originally published in 2007.
The encoder uses short and long frames as shown in the following table. (Note! A 1024 sample
window in this table corresponds to what the Ogg Vorbis community calls 2048 sample window.)
Ogg Vorbis window lengths as function of samplerate
Channel coupling is always used for stereo streams. Dual-channel audio is not supported.
For stereo streams, channel coupling is always used (as opposed to MP3, this is a lossless
operation in Ogg Vorbis). However, to save space, part of the audio spectrum is only encoded
as intensity stereo. The frequency threshold for intensity stereo depends on the quality setting.
For quality setting 0, practically all stereo information above 100 Hz is encoded as intensity
stereo. Dual-channel audio like multilingual transmissions using one stereo stream is neither
supported nor recommended.
VSOVE uses VLSI Solution’s proprietary PAMM psycho-acoustic model. PAMM is a noniterative, constant-time, processor-time efficient real-time algorithm that is capable of near CD
quality at bitrates averaging around 140 kbit/s.
VSOVE supports only VBR and makes no attempts at equalizing its output bitrate: the output
file size purely depends on the user-chosen quality setting.
7.1.2VLSI Solution’s MP3 Encoder VSMPE v1.00
VSMPE is VLSI Solution’s proprietary MP3 encoder first time published for the VS1063 in 2011.
VSMPE supports VBR and CBR.
VSMPE only uses long blocks (576 samples per block).
Version: 0.40, 2011-09-0219
PRELIMINARY
Page 20
VS1063a Prog. Guide
7AUDIO FORMAT SPECIFIC COMMENTS
For stereo audio, joint-stereo streams are always created. The encoder determines on a frameby-frame basis whether to use LR-stereo or MS-stereo. Dual-channel audio like multilingual
transmissions using one stereo stream is neither supported nor recommended.
VSMPE uses an enhanced and adapted version of the PAMM psycho-acoustic model originally
devoloped for VLSI Solution’s Ogg Vorbis encoder. The new version of PAMM includes fast
bitrate control which makes it possible to create CBR bitstreams.
When CBR is being used, lowest and highest bitrates may lead into inefficient encoding: lowest
bitrates because the encoder needs to make it sure that the maximum frame length never is
exceeded, and highest bitrates because bit reservoir cannot be trusted too much.
No attempts are made at encoding frequencies over 16 kHz, even with the highest quality settings and samplerates. The reason for this is an omission in the MP3 format specification which
makes it difficult to encode these frequencies with reasonable accuracy.
7.2Decoders
7.2.1MP3 Decoder
VS1063a’s MP3 decoder is a full-accuracy decoder.
Version: 0.40, 2011-09-0220
PRELIMINARY
Page 21
VS1063a Prog. Guide
8VS1063a Load File Formats
8.1VS1063a Plugin Format
8VS1063A LOAD FILE FORMATS
A plugin file (“.PLG”) contains an unsigned 16-bit C source code vector called
is in an RLE compressed format. An example plugin vector is shown below:
2. If (n& 0x8000U), write the next wordntimes to register
3. Else write nextnwords to register
4. Continue until table has been exhausted.
The example vector first tells to write 0x8260 to register 7 (WRAMADDR). Then write 2 words,
0x1234 and 0x5678, to register 6 (WRAM). Finally, write 0xabcd 4 times to register 6 (WRAM).
addr
and repeat numbern.
addr
.
addr
.
plugin
. The file
8.1.1The .PLG Format and VSIDE
VSIDE will gain the capability of generating plugin format files in Q3/2011.
The VS1063a image format is a bootable / loadable binary format with a three-byte header,
followed by one or more boot records. The default image file suffix is “.IMG”.
The 3-byte header is shown below:
VS1063a Boot Header, begins the file
NameBytesDescription
HEADER3“P&H” (0x50, 0x26, 0x48)
A boot record is shown below:
VS1063a Boot Record, from 1 to n, last is always TYPE = Execute