VS1053b Datasheet VS1053b Ogg Vorbis/MP3/AAC/WMA/FLAC/ MIDI AUDIO CODEC CIRCUIT Features Description VS1053b is an Ogg Vorbis/MP3/AAC/WMA/ • Decodes FLAC/WAVMIDI audio decoder as well as an Ogg Vorbis; PCM/IMA ADPCM/Ogg Vorbis encoder on a MP3 = MPEG 1 & 2 audio layer III (CBR single chip. It contains a high-performance, +VBR +ABR); proprietary low-power DSP processor core MP1/MP2 = layers I & II optional; VS_DSP4 , data memory, 16 KiB instruction MPEG4 / 2 AAC-LC(+PNS), RAM and 0.
VS1053b Datasheet CONTENTS Contents VS1053 1 Table of Contents 2 List of Figures 5 1 Licenses 6 2 Disclaimer 6 3 Definitions 6 4 Characteristics & Specifications 4.1 Absolute Maximum Ratings . . . . . . . . . 4.2 Recommended Operating Conditions . . . . 4.3 Analog Characteristics . . . . . . . . . . . . 4.4 Power Consumption . . . . . . . . . . . . . 4.5 Digital Characteristics . . . . . . . . . . . . . 4.6 Switching Characteristics - Boot Initialization . . . . . .
VS1053b Datasheet 8.3 8.4 8.5 8.6 8.7 8.8 8.9 Supported MP1 (MPEG layer I) Formats . . . . . . . . . . . . . . . Supported Ogg Vorbis Formats . . . . . . . . . . . . . . . . . . . . Supported AAC (ISO/IEC 13818-7 and ISO/IEC 14496-3) Formats Supported WMA Formats . . . . . . . . . . . . . . . . . . . . . . . Supported FLAC Formats . . . . . . . . . . . . . . . . . . . . . . . Supported RIFF WAV Formats . . . . . . . . . . . . . . . . . . . . . Supported MIDI Formats . . . . . . . . . . . . . . . . . . . .
VS1053b Datasheet 10.11 Extra Parameters . . . . . . . . . . . . 10.11.1 Common Parameters . . . . 10.11.2 WMA . . . . . . . . . . . . . 10.11.3 AAC . . . . . . . . . . . . . 10.11.4 Midi . . . . . . . . . . . . . . 10.11.5 Ogg Vorbis . . . . . . . . . . 10.12 SDI Tests . . . . . . . . . . . . . . . . 10.12.1 Sine Test . . . . . . . . . . . 10.12.2 Pin Test . . . . . . . . . . . 10.12.3 SCI Test . . . . . . . . . . . 10.12.4 Memory Test . . . . . . . . . 10.12.5 New Sine and Sweep Tests . . . . . . . . . .
VS1053b Datasheet LIST OF FIGURES List of Figures 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Pin configuration, LQFP-48. . . . . . . . . . . . . . . . . . . . . . . . . . . . VS1053b in LQFP-48 packaging. . . . . . . . . . . . . . . . . . . . . . . . . Typical connection diagram using LQFP-48. . . . . . . . . . . . . . . . . . . SDI in VS10xx Native Mode, single-byte transfer . . . . . . . . . . . . . . . SDI in VS10xx Native Mode, multi-byte transfer, X ≥ 1 . . . . . . . . . . . .
VS1053b Datasheet 1 3 DEFINITIONS Licenses MPEG Layer-3 audio decoding technology licensed from Fraunhofer IIS and Thomson. Note: If you enable Layer I and Layer II decoding, you are liable for any patent issues that may arise from using these formats. Joint licensing of MPEG 1.0 / 2.0 Layer III does not cover all patents pertaining to layers I and II. VS1053b contains WMA decoding technology from Microsoft.
VS1053b Datasheet 4 4 4.1 Characteristics & Specifications Absolute Maximum Ratings Parameter Analog Positive Supply Digital Positive Supply I/O Positive Supply Current at Any Non-Power Pin1 Voltage at Any Digital Input Operating Temperature Storage Temperature 1 2 CHARACTERISTICS & SPECIFICATIONS Symbol AVDD CVDD IOVDD Min -0.3 -0.3 -0.3 -0.3 -30 -65 Max 3.6 1.85 3.6 ±50 IOVDD+0.32 +85 +150 Unit V V V mA V ◦C ◦C Higher current can cause latch-up. Must not exceed 3.6 V 4.
VS1053b Datasheet 4 4.3 CHARACTERISTICS & SPECIFICATIONS Analog Characteristics Unless otherwise noted: AVDD=3.3V, CVDD=1.8V, IOVDD=2.8V, REF=1.65V, TA=-30..+85◦ C, XTALI=12..13MHz, Internal Clock Multiplier 3.5×. DAC tested with 1307.894 Hz full-scale output sinewave, measurement bandwidth 20..20000 Hz, analog output load: LEFT to GBUF 30 Ω, RIGHT to GBUF 30 Ω. Microphone test amplitude 48 mVpp, fs =1 kHz, Line input test amplitude 1.26 V, fs =1 kHz.
VS1053b Datasheet 4 4.4 CHARACTERISTICS & SPECIFICATIONS Power Consumption Tested with an Ogg Vorbis 128 kbps sample and generated sine. Output at full volume. Internal clock multiplier 3.0×. TA=+25◦ C. Parameter Power Supply Consumption AVDD, Reset Power Supply Consumption CVDD = 1.8V, Reset Power Supply Consumption AVDD, sine test, 30 Ω + GBUF Power Supply Consumption CVDD = 1.
VS1053b Datasheet 5 5 PACKAGES AND PIN DESCRIPTIONS Packages and Pin Descriptions 5.1 Packages LPQFP-48 is a lead (Pb) free and also RoHS compliant package. RoHS is a short name of Directive 2002/95/EC on the restriction of the use of certain hazardous substances in electrical and electronic equipment. 5.1.1 LQFP-48 48 1 Figure 1: Pin configuration, LQFP-48. LQFP-48 package dimensions are at http://www.vlsi.fi/ . Figure 2: VS1053b in LQFP-48 packaging. Version: 1.
VS1053b Datasheet 5 Pad Name MICP / LINE1 MICN XRESET DGND0 CVDD0 IOVDD0 CVDD1 DREQ GPIO2 / DCLK1 GPIO3 / SDATA1 GPIO6 / I2S_SCLK3 GPIO7 / I2S_SDATA3 XDCS / BSYNC1 IOVDD1 VCO DGND1 XTALO XTALI IOVDD2 DGND2 DGND3 DGND4 XCS CVDD2 GPIO5 / I2S_MCLK3 RX TX SCLK SI SO CVDD3 XTEST GPIO0 GPIO1 GND GPIO4 I2S_LROUT3 AGND0 AVDD0 RIGHT AGND1 AGND2 GBUF AVDD1 RCAP AVDD2 LEFT AGND3 LINE2 / PACKAGES AND PIN DESCRIPTIONS LQFP Pin 1 2 3 4 5 6 7 8 9 10 11 12 Pin Type AI AI DI DGND CPWR IOPWR CPWR DO DIO DIO DIO DIO Fun
VS1053b Datasheet 5 PACKAGES AND PIN DESCRIPTIONS 1 First pin function is active in New Mode, latter in Compatibility Mode. 2 Unless pull-down resistor is used, SPI Boot is tried. See Chapter 10.9 for details. 3 If I2S_CF_ENA is ’0’ the pins are used for GPIO. See Chapter 11.14 for details. Pin types: Type DI DO DIO DO3 AI Description Digital input, CMOS Input Pad Digital output, CMOS Input Pad Digital input/output Digital output, CMOS Tri-stated Output Pad Analog input Version: 1.
VS1053b Datasheet 6 6 CONNECTION DIAGRAM, LQFP-48 Connection Diagram, LQFP-48 Figure 3: Typical connection diagram using LQFP-48. Figure 3 shows a typical connection diagram for VS1053. Figure Note 1: Connect either Microphone In or Line In, but not both at the same time. Note: This connection assumes SM_SDINEW is active (see Chapter 9.6.1). If also SM_SDISHARE is used, xDCS should be tied low or high (see Chapter 7.1.1). Version: 1.
VS1053b Datasheet 6 CONNECTION DIAGRAM, LQFP-48 The common buffer GBUF can be used for common voltage (1.23 V) for earphones. This will eliminate the need for large isolation capacitors on line outputs, and thus the audio output pins from VS1053b may be connected directly to the earphone connector. GBUF must NOT be connected to ground under any circumstances. If GBUF is not used, LEFT and RIGHT must be provided with coupling capacitors.
VS1053b Datasheet 7 7 SPI BUSES SPI Buses The SPI Bus - which was originally used in some Motorola devices - has been used for both VS1053b’s Serial Data Interface SDI (Chapters 7.3 and 9.4) and Serial Control Interface SCI (Chapters 7.4 and 9.5). 7.1 SPI Bus Pin Descriptions 7.1.1 VS10xx Native Modes (New Mode, recommended) These modes are active on VS1053b when SM_SDINEW is set to 1 (default at startup).
VS1053b Datasheet 7.2 7 SPI BUSES Data Request Pin DREQ The DREQ pin/signal is used to signal if VS1053b’s 2048-byte FIFO is capable of receiving data. If DREQ is high, VS1053b can take at least 32 bytes of SDI data or one SCI command. DREQ is turned low when the stream buffer is too full and for the duration of an SCI command.
VS1053b Datasheet 7.3 7 SPI BUSES Serial Protocol for Serial Data Interface (SPI / SDI) The serial data interface operates in slave mode so DCLK signal must be generated by an external circuit. Data (SDATA signal) can be clocked in at either the rising or falling edge of DCLK (Chapter 9.6). VS1053b assumes its data input to be byte-sychronized. SDI bytes may be transmitted either MSb or LSb first, depending of register SCI_MODE bit SM_SDIORD (Chapter 9.6.1).
VS1053b Datasheet 7.3.2 7 SPI BUSES SDI Timing Diagram in VS10xx Native Modes (New Mode) tWL tXCSS tWH tXCSH xDCS D7 D6 D5 D4 D3 D2 tXCS D1 D0 SCK SI tH tSU Figure 6: SDI timing diagram Figure 6 presents SDI bus timing. Symbol tXCSS tSU tH tWL tWH tXCSH tXCS Min 5 0 2 2 2 1 0 Max Unit ns ns CLKI cycles CLKI cycles CLKI cycles CLKI cycles CLKI cycles Note: xDCS is not required to go high between bytes, so tXCS is 0.
VS1053b Datasheet 7.3.3 7 SPI BUSES SDI in VS1001 Compatibility Mode (deprecated, do not use in new designs) BSYNC SDATA D7 D6 D5 D4 D3 D2 D1 D0 DCLK Figure 7: SDI in VS1001 Mode - one byte transfer. Do not use in new designs! When VS1053b is running in VS1001 compatibility mode, a BSYNC signal must be generated to ensure correct bit-alignment of the input bitstream, as shown in Figures 7 and 8.
VS1053b Datasheet 7.4 7 SPI BUSES Serial Protocol for Serial Command Interface (SPI / SCI) The serial bus protocol for the Serial Command Interface SCI (Chapter 9.5) consists of an instruction byte, address byte and one 16-bit data word. Each read or write operation can read or write a single register. Data bits are read at the rising edge, so the user should update data at the falling edge. Bytes are always send MSb first.
VS1053b Datasheet 7.4.2 7 SPI BUSES SCI Write XCS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 0 0 0 0 0 0 1 0 0 0 0 30 31 SCK 3 SI instruction (write) SO 0 0 0 0 0 0 2 1 15 14 0 0 0 0 0 X data out address 0 1 0 0 0 0 0 0 0 0 0 0 X 0 execution DREQ Figure 10: SCI word write VS1053b registers are written from using the following sequence, as shown in Figure 10. First, XCS line is pulled low to select the device.
VS1053b Datasheet 7 SPI BUSES bringing XCS up after sending the last bit of a data word, the next data word is sent immediately. After the last data word, XCS is driven high as with a single word write. After the last bit of a word has been sent, DREQ is driven low for the duration of the register update, marked “execution” in the figure. The time varies depending on the register and its contents (see table in Chapter 9.6 for details).
VS1053b Datasheet 7.5 7.5.1 7 SPI BUSES SPI Examples with SM_SDINEW and SM_SDISHARED set Two SCI Writes SCI Write 1 SCI Write 2 XCS 0 1 2 3 30 31 1 0 32 33 61 62 63 2 1 0 SCK SI 0 0 0 X 0 0 X 0 DREQ up before finishing next SCI write DREQ Figure 13: Two SCI operations Figure 13 shows two consecutive SCI operations. Note that xCS must be raised to inactive state between the writes. Also DREQ must be respected as shown in the figure. 7.5.
VS1053b Datasheet 7.5.3 7 SPI BUSES SCI Operation in Middle of Two SDI Bytes SDI Byte SDI Byte SCI Operation XCS 0 7 1 8 9 39 40 41 7 6 46 47 1 0 SCK 7 6 5 1 0 0 SI 5 X 0 DREQ high before end of next transfer DREQ Figure 15: Two SDI bytes separated by an SCI operation Figure 15 shows how an SCI operation is embedded in between SDI operations. xCS edges are used to synchronize both SDI and SCI. Remember to respect DREQ as shown in the figure. Version: 1.
VS1053b Datasheet 8 8 Supported Audio Decoder Formats Mark + ? - 8.1 SUPPORTED AUDIO DECODER FORMATS Conventions Description Format is supported Format is supported but not thoroughly tested Format exists but is not supported Format doesn’t exist Supported MP3 (MPEG layer III) Formats MPEG 1.
VS1053b Datasheet 8 8.2 SUPPORTED AUDIO DECODER FORMATS Supported MP2 (MPEG layer II) Formats Note: Layer I / II decoding must be specifically enabled from register SCI_MODE. MPEG 1.
VS1053b Datasheet 8 8.5 SUPPORTED AUDIO DECODER FORMATS Supported AAC (ISO/IEC 13818-7 and ISO/IEC 14496-3) Formats VS1053b decodes MPEG2-AAC-LC-2.0.0.0 and MPEG4-AAC-LC-2.0.0.0 streams, i.e. the low complexity profile with maximum of two channels can be decoded. If a stream contains more than one element and/or element type, you can select which one to decode from the 16 singlechannel, 16 channel-pair, and 16 low-frequency elements. The default is to select the first one that appears in the stream.
VS1053b Datasheet 8 SUPPORTED AUDIO DECODER FORMATS mdat atom last in the file, and thus suitable for web servers’ audio streaming. You can use this kind of tool to process files for VS1053b too. For example mp4creator -optimize file.mp4.
VS1053b Datasheet 8 8.6 SUPPORTED AUDIO DECODER FORMATS Supported WMA Formats Windows Media Audio codec versions 2, 7, 8, and 9 are supported. All WMA profiles (L1, L2, and L3) are supported. Previously streams were separated into Classes 1, 2a, 2b, and 3. The decoder has passed Microsoft’s conformance testing program. Windows Media Audio Professional is a different codec and is not supported. WMA 4.0 / 4.
VS1053b Datasheet 8 8.7 SUPPORTED AUDIO DECODER FORMATS Supported FLAC Formats Upto 48 kHz and 24-bit FLAC files are supported with the VS1053b Patches w/ FLAC Decoder plugin that is available at http://www.vlsi.fi/en/support/software/vs10xxplugins.html . Read the accompanying documentation of the plugin for details. 8.8 Supported RIFF WAV Formats The most common RIFF WAV subformats are supported, with 1 or 2 audio channels.
VS1053b Datasheet 8 8.9 SUPPORTED AUDIO DECODER FORMATS Supported MIDI Formats General MIDI and SP-MIDI format 0 files are played. Format 1 and 2 files must be converted to format 0 by the user. The maximum polyphony is 64, the maximum sustained polyphony is 40.
VS1053b Datasheet 8 1 Acoustic Grand Piano 2 Bright Acoustic Piano 3 Electric Grand Piano 4 Honky-tonk Piano 5 Electric Piano 1 6 Electric Piano 2 7 Harpsichord 8 Clavi 9 Celesta 10 Glockenspiel 11 Music Box 12 Vibraphone 13 Marimba 14 Xylophone 15 Tubular Bells 16 Dulcimer 17 Drawbar Organ 18 Percussive Organ 19 Rock Organ 20 Church Organ 21 Reed Organ 22 Accordion 23 Harmonica 24 Tango Accordion 25 Acoustic Guitar (nylon) 26 Acoustic Guitar (steel) 27 Electric Guitar (jazz) 28 Electric Guitar (clean) 29
VS1053b Datasheet 9 9 9.1 FUNCTIONAL DESCRIPTION Functional Description Main Features VS1053b is based on a proprietary digital signal processor, VS_DSP. It contains all the code and data memory needed for Ogg Vorbis, MP3, AAC, WMA and WAV PCM + ADPCM audio decoding and a MIDI synthesizer, together with serial interfaces, a multirate stereo audio DAC and analog output amplifiers and filters.
VS1053b Datasheet 9 9.2 FUNCTIONAL DESCRIPTION Data Flow of VS1053b SDI Bitstream FIFO MP3 MP2 MP1 WAV ADPCM WMA AAC MIDI Vorbis SM_ADPCM=0 SB_AMPLITUDE=0 AIADDR = 0 Bass enhancer User Application Treble control SB_AMPLITUDE!=0 AIADDR != 0 Audio FIFO 2048 stereo samples ST_AMPLITUDE=0 Ear Speaker ST_AMPLITUDE!=0 L S.rate.conv. R and DAC Volume SCI_VOL control Figure 16: Data flow of VS1053b.
VS1053b Datasheet 9 9.3 FUNCTIONAL DESCRIPTION EarSpeaker Spatial Processing While listening to headphones the sound has a tendency to be localized inside the head. The sound field becomes flat and lacking the sensation of dimensions. This is an unnatural, awkward and sometimes even disturbing situation. This phenomenon is often referred in literature as ‘lateralization’, meaning ’in-the-head’ localization. Long-term listening to lateralized sound may lead to listening fatigue.
VS1053b Datasheet 9 FUNCTIONAL DESCRIPTION • normal: Suited for listening to normal musical scores with headphones, moves sound source further away than minimal. • extreme: Suited for old or ’dry’ recordings, or if the audio to be played is artificial, for example generated MIDI. 9.4 Serial Data Interface (SDI) The serial data interface is meant for transferring compressed data for the different decoders of VS1053b.
VS1053b Datasheet 9 9.6 FUNCTIONAL DESCRIPTION SCI Registers VS1053b sets DREQ low when it detects an SCI operation (this delay is 16 to 40 CLKI cycles depending on whether an interrupt service routine is active) and restores it when it has processed the operation. The duration depends on the operation. If DREQ is low when an SCI operation is performed, it also stays low after SCI operation processing.
VS1053b Datasheet 9 9.6.1 FUNCTIONAL DESCRIPTION SCI_MODE (RW) SCI_MODE is used to control the operation of VS1053b and defaults to 0x4800 (SM_SDINEW set).
VS1053b Datasheet 9 FUNCTIONAL DESCRIPTION Bits SM_EARSPEAKER_LO and SM_EARSPEAKER_HI control the EarSpeaker spatial processing. If both are 0, the processing is not active. Other combinations activate the processing and select 3 different effect levels: LO = 1, HI = 0 selects minimal, LO = 0, HI = 1 selects normal, and LO = 1, HI = 1 selects extreme. EarSpeaker takes approximately 12 MIPS at 44.1 kHz samplerate. If SM_TESTS is set, SDI tests are allowed. For more details on SDI tests, look at Chapter 10.
VS1053b Datasheet 9 9.6.2 FUNCTIONAL DESCRIPTION SCI_STATUS (RW) SCI_STATUS contains information on the current status of VS1053b. It also controls some low-level things that the user does not usually have to care about. Name SS_DO_NOT_JUMP SS_SWING SS_VCM_OVERLOAD SS_VCM_DISABLE SS_VER SS_APDOWN2 SS_APDOWN1 SS_AD_CLOCK SS_REFERENCE_SEL Bits 15 14:12 11 10 9:8 7:4 3 2 1 0 Description Header in decode, do not fast forward/rewind Set swing to +0 dB, +0.5 dB, .., or +3.
VS1053b Datasheet 9 9.6.3 FUNCTIONAL DESCRIPTION SCI_BASS (RW) Name ST_AMPLITUDE ST_FREQLIMIT SB_AMPLITUDE SB_FREQLIMIT Bits 15:12 11:8 7:4 3:0 Description Treble Control in 1.5 dB steps (-8..7, 0 = off) Lower limit frequency in 1000 Hz steps (1..15) Bass Enhancement in 1 dB steps (0..15, 0 = off) Lower limit frequency in 10 Hz steps (2..15) The Bass Enhancer VSBE is a powerful bass boosting DSP algorithm, which tries to take the most out of the users earphones without causing clipping.
VS1053b Datasheet 9 9.6.4 FUNCTIONAL DESCRIPTION SCI_CLOCKF (RW) The external clock multiplier SCI register SCI_CLOCKF, which has changed slightly since VS1003 and VS1033, is presented in the table below. Name SC_MULT SC_ADD SC_FREQ SCI_CLOCKF bits Bits Description 15:13 Clock multiplier 12:11 Allowed multiplier addition 10: 0 Clock frequency SC_MULT activates the built-in clock multiplier. This will multiply XTALI to create a higher CLKI. When the multiplier is changed by more than 0.
VS1053b Datasheet 9 9.6.5 FUNCTIONAL DESCRIPTION SCI_DECODE_TIME (RW) When decoding correct data, current decoded time is shown in this register in full seconds. The user may change the value of this register. In that case the new value should be written twice to make absolutely certain that the change is not overwritten by the firmware. A write to SCI_DECODE_TIME also resets the byteRate calculation. SCI_DECODE_TIME is reset at every hardware and software reset.
VS1053b Datasheet 9 WRAMADDR Start. . . End 0x1800. . . 0x18XX 0x5800. . . 0x58XX 0x8040. . . 0x84FF 0xC000. . . 0xFFFF Dest. addr. Start. . . End 0x1800. . . 0x18XX 0x1800. . . 0x18XX 0x0040. . . 0x04FF 0xC000. . . 0xFFFF Bits/ Word 16 16 32 16 FUNCTIONAL DESCRIPTION Description X data RAM Y data RAM Instruction RAM I/O Only user areas in X, Y, and instruction memory are listed above. Other areas can be accessed, but should not be written to unless otherwise specified. 9.6.
VS1053b Datasheet 9 Bit HDAT1[15:5] HDAT1[4:3] Function syncword ID HDAT1[2:1] layer HDAT1[0] protect bit HDAT0[15:12] HDAT0[11:10] bitrate samplerate HDAT0[9] pad bit HDAT0[8] HDAT0[7:6] private bit mode HDAT0[5:4] HDAT0[3] extension copyright HDAT0[2] original HDAT0[1:0] emphasis Value 2047 3 2 1 0 3 2 1 0 1 0 3 2 1 0 1 0 3 2 1 0 1 0 1 0 3 2 1 0 FUNCTIONAL DESCRIPTION Explanation stream valid ISO 11172-3 MPG 1.0 ISO 13818-3 MPG 2.0 (1/2-rate) MPG 2.5 (1/4-rate) MPG 2.
VS1053b Datasheet 9 “bitrate” 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Layer I ID=3 ID=0,1,2 kbit/s forbidden forbidden 448 256 416 224 384 192 352 176 320 160 288 144 256 128 224 112 192 96 160 80 128 64 96 56 64 48 32 32 - Layer II ID=3 ID=0,1,2 kbit/s forbidden forbidden 384 160 320 144 256 128 224 112 192 96 160 80 128 64 112 56 96 48 80 40 64 32 56 24 48 16 32 8 - FUNCTIONAL DESCRIPTION Layer III ID=3 ID=0,1,2 kbit/s forbidden forbidden 320 160 256 144 224 128 192 112 160 96 128 80 112 64 96 56 80 48
VS1053b Datasheet 9 9.6.11 FUNCTIONAL DESCRIPTION SCI_VOL (RW) SCI_VOL is a volume control for the player hardware. The most significant byte of the volume register controls the left channel volume, the low part controls the right channel volume. The channel volume sets the attenuation from the maximum volume level in 0.5 dB steps. Thus, maximum volume is 0x0000 and total silence is 0xFEFE. Note, that after hardware reset the volume is set to full volume.
VS1053b Datasheet 10 10.1 10 OPERATION Operation Clocking VS1053b operates on a single, nominally 12.288 MHz fundamental frequency master clock. This clock can be generated by external circuitry (connected to pin XTALI) or by the internal clock crystal interface (pins XTALI and XTALO). This clock is used by the analog parts and determines the highest available samplerate. With 12.288 MHz clock all samplerates upto 48000 Hz are available. VS1053b can also use 24..
VS1053b Datasheet 10 OPERATION will stay down for about 22000 clock cycles, which means an approximate 1.8 ms delay if VS1053b is run at 12.288 MHz. After DREQ is up, you may continue playback as usual. As opposed to all earlier VS10XX chips, it is not recommended to do a software reset between songs. This way the user may be sure that even files with low samplerates or bitrates are played right to their end. 10.
VS1053b Datasheet 10.5.1 10 OPERATION Playing a Whole File This is the default playback mode. 1. 2. 3. 4. 5. 6. Send an audio file to VS1053b. Read extra parameter value endFillByte (Chapter 10.11). Send at least 2052 bytes of endFillByte[7:0]. Set SCI_MODE bit SM_CANCEL. Send at least 32 bytes of endFillByte[7:0]. Read SCI_MODE. If SM_CANCEL is still set, go to 5. If SM_CANCEL hasn’t cleared after sending 2048 bytes, do a software reset (this should be extremely rare). 7.
VS1053b Datasheet 10.5.4 10 OPERATION Fast Forward and Rewind without Audio To do fast forward and rewind you need the capability to do random access to the audio file. Unfortunately fast forward and rewind isn’t available at all times, like when file headers are being read. 1. Send a portion of an audio file to VS1053b. 2. When random access is required, read SCI_STATUS bit SS_DO_NOT_JUMP. If that bit is set, random access cannot be performed, so go back to 1. 3.
VS1053b Datasheet 10.6 10 OPERATION Feeding PCM data VS1053b can be used as a PCM decoder by sending a WAV file header. If the length sent in the WAV header is 0xFFFFFFFF, VS1053b will stay in PCM mode indefinitely (or until SM_CANCEL has been set). 8-bit linear and 16-bit linear audio is supported in mono or stereo.
VS1053b Datasheet 10.8 10 OPERATION PCM/ADPCM Recording This chapter explains how to create RIFF/WAV file in PCM or IMA ADPCM format. IME ADPCM is a widely supported ADPCM format and many PC audio playback programs can play it. IMA ADPCM recording gives roughly a compression ratio of 4:1 compared to linear, 16-bit audio. This makes it possible to record for example ono 8 kHz audio at 32.44 kbit/s.
VS1053b Datasheet 10 OPERATION WriteVS10xxPatch() should perform the following SCI writes (only for VS1053b and VS8053b): Register SCI_WRAMADDR SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAM SCI_WRAMADDR SCI_WRAM SCI_WRAM Reg.
VS1053b Datasheet 10 OPERATION IMA ADPCM block is 256 words, i.e. 512 bytes. If you wish to interrupt reading data and possibly continue later, please stop at the boundary. This way whole blocks are skipped and the encoded stream stays valid. 10.8.3 Adding a PCM RIFF Header To make your PCM file a RIFF / WAV file, you have to add a header to the data. The following shows a header for a mono file. Note that 2- and 4-byte values are little-endian (lowest byte first).
VS1053b Datasheet 10.8.4 10 OPERATION Adding an IMA ADPCM RIFF Header To make your IMA ADPCM file a RIFF / WAV file, you have to add a header to the data. The following shows a header for a mono file. Note that 2- and 4-byte values are little-endian (lowest byte first).
VS1053b Datasheet 0000 0010 0020 0030 10.8.5 52 14 00 14 49 00 02 15 46 00 04 97 46 00 00 00 34 11 02 64 2e 00 00 61 99 02 f9 74 00 00 01 61 57 44 66 00 41 ac 61 2e 56 00 63 99 10 OPERATION 45 66 6d 74 20 |RIFF4...WAVEfmt | 00 a7 ae 00 00 |........D.......| 74 04 00 00 00 |........fact....| 00 |....data....| Playing ADPCM Data In order to play back your PCM / IMA ADPCM recordings, you have to have a file with a header as described in Chapter 10.8.3 or Chapter 10.8.4.
VS1053b Datasheet dB -0.0 -0.5 -1.0 -1.5 -2.0 -2.5 -3.0 -3.5 -4.0 -4.5 -5.0 -5.5 -6.0 DAC_VOL 0x0000 0xb1b1 0xa1a1 0x9191 0x8181 0x7171 0x6161 0x5151 0x4141 0x3131 0x2121 0x1111 0x0101 dB -6.5 : -12.0 -12.5 : -18.0 -18.5 : -24.0 -24.5 : -30.0 -30.5 Version: 1.20, 2012-12-03 DAC_VOL 0xb2b2 : 0x0202 0xb3b3 : 0x0303 0xb4b4 : 0x0404 0xb5b5 : 0x0505 0xb6b6 dB : -36.0 -36.5 : -42.0 -42.5 : -48.0 -48.5 : -54.0 -54.5 : DAC_VOL : 0x0606 0xb7b7 : 0x0707 0xb8b8 : 0x0808 0xb9b9 : 0x0909 0xbaba : dB -60.0 -60.
VS1053b Datasheet 10.9 10 OPERATION SPI Boot If GPIO0 is set with a pull-up resistor to 1 at boot time, VS1053b tries to boot from external SPI memory. SPI boot redefines the following pins: Normal Mode GPIO0 GPIO1 DREQ GPIO2 SPI Boot Mode xCS CLK MOSI MISO The memory has to be an SPI Bus Serial EEPROM with 16-bit or 24-bit addresses. The serial speed used by VS1053b is 245 kHz with the nominal 12.288 MHz clock. The first three bytes in the memory have to be 0x50, 0x26, 0x48. 10.
VS1053b Datasheet 10.11 10 OPERATION Extra Parameters The following structure is in X memory at address 0x1e02 (note the different location than in VS1033) and can be used to change some extra parameters or get useful information.
VS1053b Datasheet 10 OPERATION You can see that in the invalid read the low part wraps from 0x0000 to 0xffff while the high part stays the same. In this case the second read gives a valid answer, otherwise always use the value of the first read. The second read is needed when it is possible that the low part wraps around, changing the high part, i.e. when the low part is small. bytesLeft is only decreased by one at a time, so a reread is needed only if the low part is 0. 10.11.
VS1053b Datasheet 10 OPERATION implement perfect fast forward and rewind for WMA and AAC (ADIF, .mp4 / .m4a). positionMsec is a field that gives the current play position in a file in milliseconds, regardless of rewind and fast forward operations. The value is only available in codecs that can determine the play position from the stream itself. Currently WMA and Ogg Vorbis provide this information. If the position is unknown, this field contains -1.
VS1053b Datasheet 10.11.3 10 OPERATION AAC Parameter config1 sceFoundMask cpeFoundMask lfeFoundMask playSelect dynCompress dynBoost sbrAndPsStatus Address 0x1e03(7:4) 0x1e2a 0x1e2b 0x1e2c 0x1e2d 0x1e2e 0x1e2f 0x1e30 Usage SBR and PS select Single channel elements found Channel pair elements found Low frequency elements found Play element selection Compress coefficient for DRC, -8192=1.0 Boost coefficient for DRC, 8192=1.
VS1053b Datasheet config1(7:6) ’00’ ’01’ ’10’ ’11’ 10 OPERATION Usage normal mode, process PS if it is available process PS if it is available, but in downsampled mode reserved disable PS processing AAC decoder can also increase the internal clock automatically when it detects that a file can not be decoded correctly with the current clock. The maximum allowed clock is configured with the SCI_CLOCKF register.
VS1053b Datasheet 10 OPERATION For example gain = -11 means that volume should be decreased by 5.5 dB (−11/2 = −5.5), and left and right attenuation should be increased by 11. When gain = 2 volume should be increased by 1 dB (2/2 = 1.0), and left and right attenuation should be decreased by 2. Because volume setting can not go above +0 dB, the value should be saturated. Gain -11 (-5.5 dB) -11 (-5.5 dB) +2 (+1.0 dB) +2 (+1.0 dB) +2 (+1.0 dB) Volume 0 (+0.0 dB) 3 (-1.5 dB) 0 (+0.0 dB) 1 (-0.5 dB) 4 (-2.
VS1053b Datasheet 10.12 10 OPERATION SDI Tests There are several test modes in VS1053b, which allow the user to perform memory tests, SCI bus tests, and several different sine wave tests. All tests are started in a similar way: VS1053b is hardware reset, SM_TESTS is set, and then a test command is sent to the SDI bus. Each test is started by sending a 4-byte special command sequence, followed by 4 zeros. The sequences are described below. 10.12.
VS1053b Datasheet 10 OPERATION the register to be tested is HDAT0, the result is copied to SCI_HDAT1. Example: if n is 0, contents of SCI register 0 (SCI_MODE) is copied to SCI_HDAT0. 10.12.4 Memory Test Memory test mode is initialized with the 8-byte sequence 0x4D 0xEA 0x6D 0x54 0 0 0 0. After this sequence, wait for 1100000 clock cycles.
VS1053b Datasheet 10 OPERATION Fsin = SCI_AICT RLn × F s /65536 Sine sweep test can be started by writing 0x4022 to SCI_AIADDR. Both these tests use the normal audio path, thus also SCI_BASS, differential output mode, and EarSpeaker settings have an effect. Version: 1.
VS1053b Datasheet 11 11 11.1 VS1053B REGISTERS VS1053b Registers Who Needs to Read This Chapter User software is required when a user wishes to add some own functionality like DSP effects to VS1053b. However, most users of VS1053b don’t need to worry about writing their own code, or about this chapter, including those who only download software plug-ins from VLSI Solution’s Web site. Note: Also see VS1063 Hardware Guide for more information, because the hardware is compatible with VS1053. 11.
VS1053b Datasheet 11 11.3 VS1053B REGISTERS VS1053b Hardware DAC Audio Paths Registers DAC_FCTLL DAC_FCTLH Register DAC_VOL Left Registers DAC_LEFT DAC_RIGHT Sigma−delta modulator DAC SRC Analog driver Right CBUF I2S Resampler SRC Register SRC_CONTROL Registers SRC_LEFT SRC_RIGHT Sidestream SDM Registers SDM_LEFT SDM_RIGHT Register SDM_CONTROL Figure 18: VS1053b ADC and DAC data paths with some data registers Figure 18 presents the VS1053b Hardware DAC audio paths.
VS1053b Datasheet 11 11.4 VS1053B REGISTERS VS1053b Hardware ADC Audio Paths MICN MICP Microphone amplifier LINE1 Multiplexer ADC LINE2 ADC decimator Registers ADC_DATA_LEFT ADC_DATA_RIGHT Figure 19: VS1053b ADC and DAC data paths with some data registers Figure 18 presents the VS1053b Hardware ADC audio paths. Analog audio may be fed upto two channels: one as a differential signal to MICN/MICP or as a one-sided signal to Line1, and the other as a one-sided signal to Line2.
VS1053b Datasheet 11 11.5 VS1053b Memory Map X-memory Address Description 0x0000..0x17ff System RAM 0x1800..0x187f User RAM 0x1880..0x197f Stack 0x1980..0x3fff System RAM 0x4000..0xbfff ROM 32k 0xc000..0xc0ff Peripherals 0xc100..0xffff ROM 15.75k 11.6 VS1053B REGISTERS Y-memory Address Description 0x0000..0x17ff System RAM 0x1800..0x187f User RAM 0x1880..0x197f Stack 0x1980..0x3fff System RAM 0x4000..0xdfff ROM 40k 0xe000..0xffff System RAM I-memory Address Description 0x0000..
VS1053b Datasheet 11 11.
VS1053b Datasheet 11 VS1053B REGISTERS • Select PLL clock multiplier At the core of the PLL controller is the VCO, a high frequency oscillator, whose oscillation frequency is adjusted to be an integer multiple of some input frequency. As the name “PhaseLocked Loop” suggests, this is done by comparing the phase of the input frequency against the phase of a signal which is derived from the VCO output through frequency division. If the system is stable, e.g.
VS1053b Datasheet 11 11.10 VS1053B REGISTERS GPIO Reg 0xC017 0xC018 0xC019 Type rw r rw Reset 0 0 0 GPIO registers, prefix GPIO_ Abbrev[bits] Description DDR[7:0] Direction IDATA[11:0] Values read from the pins ODATA[7:0] Values set to the pins GPIO_DIR is used to set the direction of the GPIO pins. 1 means output. GPIO_ODATA remembers its values even if a GPIO_DIR bit is set to input. GPIO_IDATA is used to read the pin states.
VS1053b Datasheet 11 11.11 VS1053B REGISTERS Interrupt Control Reg 0xC01A 0xC01B 0xC01C 0xC01D Type rw w w rw Reset 0 0 0 0 Interrupt registers, prefix INT_ Abbrev[bits] Description ENABLE[9:0] Interrupt enable GLOB_DIS[-] Write to add to interrupt counter GLOB_ENA[-] Write to subtract from interrupt counter COUNTER[4:0] Interrupt counter INT_ENABLE controls the interrupts.
VS1053b Datasheet 11 11.12 VS1053B REGISTERS UART RS232 UART implements a serial interface using rs232 standard. Start bit D0 D1 D2 D3 D4 D5 D6 Stop D7 bit Figure 20: RS232 serial interface protocol When the line is idling, it stays in logic high state. When a byte is transmitted, the transmission begins with a start bit (logic zero) and continues with data bits (LSB first) and ends up with a stop bit (logic high). 10 bits are sent for each 8-bit byte frame. 11.12.
VS1053b Datasheet 11 VS1053B REGISTERS UART_ST_TXRUNNING is set if the transmitter shift register is in operation. 11.12.3 Data UART_DATA A read from UART_DATA returns the received byte in bits 7:0, bits 15:8 are returned as ’0’. If there is no more data to be read, the receiver data register full indicator will be cleared. A receive interrupt will be generated when a byte is moved from the receiver shift register to the receiver data register. A write to UART_DATA sets a byte for transmission.
VS1053b Datasheet 11 VS1053B REGISTERS Example UART Speeds, fm = 49.152 M Hz Comm. Speed [bps] UART_DIV_D1 UART_DIV_D2 4800 255 40 9600 255 20 14400 233 15 19200 255 10 28800 243 7 38400 159 8 57600 121 7 115200 60 7 11.12.6 UART Interrupts and Operation Transmitter operates as follows: After an 8-bit word is written to the transmit data register it will be transmitted instantly if the transmitter is not busy transmitting the previous byte. When the transmission begins a TX_INTR interrupt will be sent.
VS1053b Datasheet 11 11.13 VS1053B REGISTERS Timers There are two 32-bit timers that can be initialized and enabled independently of each other. If enabled, a timer initializes to its start value, written by a processor, and starts decrementing every clock cycle. When the value goes past zero, an interrupt is sent, and the timer initializes to the value in its start value register, and continues downcounting. A timer stays in that loop as long as it is enabled.
VS1053b Datasheet 11 11.13.3 Configuration TIMER_ENABLE Name TIMER_EN_T1 TIMER_EN_T0 11.13.4 VS1053B REGISTERS TIMER_ENABLE Bits Bits Description 1 Enable timer 1 0 Enable timer 0 Timer X Startvalue TIMER_Tx[L/H] The 32-bit start value TIMER_Tx[L/H] sets the initial counter value when the timer is reset. The fi timer interrupt frequency ft = c+1 where fi is the master clock obtained with the clock divider (see Chapter 11.13.2 and c is TIMER_Tx[L/H].
VS1053b Datasheet 11 11.14 VS1053B REGISTERS I2S DAC Interface The I2S Interface makes it possible to attach an external DAC to the system. Note: The samplerate of the audio file and the I2S rate are independent. All audio will be automatically converted to 6.144 MHz for VS1053 DAC and to the configured I2S rate using a high-quality sample-rate converter. Note: In VS1053b the I2S pins share different GPIO pins than in VS1033 to be able to use SPI boot and I2S in the same application.
VS1053b Datasheet 11 11.15 VS1053B REGISTERS Analog-to-Digital Converter (ADC) ADC modulator registers control Analog-to-Digital conversions of VS1053b. Reg 0xC042 0xC043 0xC044 Type rw r r Reset 0 0 0 ADC Decimator registers, prefix ADC_ Abbrev[bits] Description CONTROL[4:0] ADC control DATA_LEFT ADC left channel data DATA_RIGHT ADC right channel data ADC_CONTROL controls the ADC and its associated decimator unit.
VS1053b Datasheet 11 11.16 VS1053B REGISTERS Resampler SampleRate Converter (SRC) The resampler SRC makes it possible to catch audio from the DAC path. Note: hardware makes no attempts at low-pass filtering data. If the SRC samplerate is lower than the DAC samplerate, aliasing may and will occur.
VS1053b Datasheet 11 11.17 VS1053B REGISTERS Sidestream Sigma-Delta Modulator (SDM) The Sidestream Sigma-Delta Modulator makes it possible to insert a digital side stream on top of existing audio. Note: The SDM provides a direct, low-delay side channel to the Sigma-Delta DACs of VS10xx. It makes no attempts at low-pass filtering data. Thus there will be practically no image rejection. If using low samplerates, this may cause audible aliasing distortion.
VS1053b Datasheet 12 12 VERSION CHANGES Version Changes This chapter describes the lastest and most important changes done to VS1053b 12.1 Changes Between VS1033c and VS1053a/b Firmware, 2007-03-08 Completely new or major changes: • I2S pins are now in GPIO4-GPIO7 and do not overlap with SPI boot pins. • No software reset required between files when used correctly. • Ogg Vorbis decoding added. Non-fatal ogg or vorbis decode errors cause automatic resync. This allows easy rewind and fast forward.
VS1053b Datasheet 12 VERSION CHANGES • Read and write to YRAM at 0xe000..0xffff added to SCI_WRAMADDR/SCI_WRAM. • The resync parameter (parametric_x.resync) is set to 32767 after reset to allow inifinite resynchronization attempts (or until SM_CANCEL is set). Old operation can be restored by writing 0 to resync after reset. • WMA,AAC: more robust resync. • WMA,AAC: If resync is performed, broadcast mode is automatically activated.
VS1053b Datasheet 13 13 DOCUMENT VERSION CHANGES Document Version Changes This chapter describes the most important changes to this document. Version 1.20, 2012-12-03 • Major update to Chapter 11 VS1053b Registers. Added Chapter 11.3, VS1053b Hardware DAC Audio Paths, Chapter 11.4, VS1053b Hardware ADC Audio Paths, Chapter 11.9, PLL Controller, Chapter 11.15, Analog-to-Digital Converter (ADC), Chapter 11.16, Resampler SampleRate Converter (SRC), and Chapter 11.
VS1053b Datasheet 14 14 CONTACT INFORMATION Contact Information VLSI Solution Oy Entrance G, 2nd floor Hermiankatu 8 FI-33720 Tampere FINLAND Fax: +358-3-3140-8288 Phone: +358-3-3140-8200 Email: sales@vlsi.fi URL: http://www.vlsi.fi/ Version: 1.
P UBLIC D OCUMENT VS1053 B O GG VORBIS E NCODER VSMPG “VLSI Solution Audio Decoder” Project Code: Project Name: VSMPG All information in this document is provided as-is without warranty. Features are subject to change without notice. Revision History Rev. 1.70c 1.70b 1.70 1.60d 1.60c 1.60b 1.60 1.50 1.40 1.31 1.30 1.21 1.20 1.10 1.01 1.00 Rev. 1.
VS1053 B O GG VORBIS E NCODER VSMPG HH Contents Rev. 1.70c VS1053b Ogg Vorbis Encoder Front Page 1 Table of Contents 2 1 Introduction 4 2 Using the Ogg Vorbis Encoder 2.1 Limitations and Requirements . . . . . . . . . . . . . . . . . . 2.2 Ogg Vorbis Encoder Profiles . . . . . . . . . . . . . . . . . . . 2.2.1 Profile Groups . . . . . . . . . . . . . . . . . . . . . . 2.2.2 Profile Quality Settings . . . . . . . . . . . . . . . . . . 2.3 Running the VS1053b Ogg Vorbis Encoder . . . . . . . . . .
VS1053 B O GG VORBIS E NCODER VSMPG HH 5.3 Playback Speed Adjustment . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4 Streaming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 37 6 Latest Version Changes 38 7 Contact Information 39 List of Figures 1 2 3 4 5 Rev. 1.70c Example colour VU meter. . . . . . . . . . . . . . Example monochrome VU meter. . . . . . . . . . Real record display with monochrome VU meter. Vox / Pause logic. . . . . . . . . . . . . . . . . . .
VS1053 B O GG VORBIS E NCODER VSMPG HH 1 Introduction The VS1053b allows the user to encode files into the highly efficient Ogg Vorbis format. This makes it possible for the user to build a device that can record high-quality stereo sound while retaining moderate file sizes. This document is an instruction manual on how to use the VS1053b Ogg Vorbis encoder application as well as an introduction to the Ogg Vorbis format itself. Example code in C is also provided.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2 Using the Ogg Vorbis Encoder The VS1053b Ogg Vorbis Encoder application is provided as a plugin in the same package as this document, downloadable at http://www.vlsi.fi/en/support/software/vs10xxapplications.html . Before loading the application into your VS1053b, select one of the profiles shown below. 2.1 Limitations and Requirements • Maximum SPI (SCI) clock speed is 3.5 Mbit/s. If a higher speed is used, there may be occasional data read errors. 2.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.2.2 Profile Quality Settings Each of the low-sample-rate profile groups has eleven quality profiles, numbered from 00 to 10. The high-sample-rate profile groups have six quality profiles from 00 to 05. This chapter presents the five profile groups and gives estimates of typical bitrates that can be obtained with the profile. In general, quality setting 05 is designed to be a typical value that gives good quality for the application.
VS1053 B O GG VORBIS E NCODER VSMPG HH The “HiFi Voice” Profiles When extremely high quality speech is required, use the “HiFi Voice” profiles. These profiles support Vox and Pause. However, Vox works best with the “Voice” and “Wideband Voice” profiles. HiFi Voice Profile number 00 01 02 Typical kbit/s 36 49 59 03 71 04 79 05 87 The “Music” Profiles The “Music” profiles are intended for HiFi music, and are capable of offering very highquality stereo sound. These profiles don’t support Vox and Pause.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.3 Running the VS1053b Ogg Vorbis Encoder This chapter will describe how to load and run the Ogg Vorbis Encoder. A C language source file vs1053oggrec.c has been included in this package as an example. 2.3.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.3.2 Loading and Starting the Code To load and start the VS1053b Ogg Vorbis Encoder, do the following steps: 1. Set the VS1053b clock to the highest value just below 55.3 MHz. Example: if the external clock is 12.288 MHz, this can be done by setting the clock to 4.5X, or 55.296 MHz by writing 0xC000 to register SCI_CLOCKF (3). If you use another input clock, adjust SCI_CLOCKF accordingly. Examples: Value for 12 MHz is 0xC3e8, 12.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.3.3 Reading Ogg Vorbis Data After Ogg Vorbis recording has been activated, registers SCI_HDAT0 and SCI_HDAT1 have new functions. The Ogg Vorbis bitstream buffer size is 4096 16-bit words, or 8 KiB. The fill status of the buffer can be read from SCI_HDAT1. If SCI_HDAT1 is greater than 0, you can read that many 16-bit words from SCI_HDAT0. If data is not read fast enough from SCI_HDAT0, the buffer overflows and returns to empty state.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.3.4 Reading Additional Data while Recording Ogg Vorbis You can get extra side information while recording Ogg Vorbis data to see whether VS1053b is still working.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.4 Recording Levels and Automatic Gain Control (AGC) The VS1053b Ogg Vorbis Encoder offers signal level monitoring through SCI_AICTRL0. It is recommended that devices that offer recording would show a signal level in a decibel scale. For the decibel scale, see Chapter 2.4.4. This can be done by showing and clearing SCI_AICTRL0 contents at regular intervals.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.4.2 Setting AGC When the highest dynamic range and sound fidelity is required, AGC should be turned off and recording gain should be set to 1 (SCI_AICTRL1 = 1024). A good example of this would be music recording. This is particularly recommended for the “HiFi Voice” and “Music” profiles, although there might be cases where recording level control would be needed even with these cases.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.4.3 Building a Useful VU Meter In an encoder application, if the recording level is too low, extraneous background noise may be introduced to the sound. Conversely, if the recording level is so high that the highest values cannot be represented numerically, signal clipping occurs, and this may cause severe distortion to sound.
VS1053 B O GG VORBIS E NCODER VSMPG HH Figure 3: Real record display with monochrome VU meter. Figure 3 shows a real implementation of a recording display that uses a Monochrome VU Meter. Information shown on the top line includes recording time, free disc space, overload warning and a bitrate counter. All this data except from the free disc space number have been obtained from the VS1053b Ogg Vorbis Encoder.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.4.4 Converting from Linear to Decibel Scale To convert from linear to dB scale, use the formula m dB = 20 × log10 ( 32768 ) + 96 where dB is the result and m is a value returned by the Recording Level Meter.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.4.5 vs1053oggrec.c The file vs1053oggrec.c, quoted below, has also been included in the VS1053b Ogg Vorbis Encoder package. /* Example code how to implement VS1053 Ogg Vorbis recording using the VS1053 Ogg Vorbis Recording plugin. The code is generic enough so that it should pretty much compile and run on any microcontroller. The code makes the following assumptions: -
VS1053 B O GG VORBIS E NCODER VSMPG HH #define SCIR_AICTRL1 #define SCIR_AICTRL2 #define SCIR_AICTRL3 13 14 15 /* returns minimum of two given numbers */ #define min(a,b) (((a)<(b))?(a):(b)) /* Loads an image file into VS1053 from a file.
VS1053 B O GG VORBIS E NCODER VSMPG HH /* If loading failed, give up. */ if (pluginStartAddr == 0xFFFF) goto end; /* Now open output file. It's better to do this before activating recording so that even if opening the output file is slow, you will not lose audio data. */ outFP = fopen("record.ogg", "wb"); if (!outFP) goto end; /* Set VS1053 mode bits as instructed in the VS1053b Ogg Vorbis Encoder manual.
VS1053 B O GG VORBIS E NCODER VSMPG HH if (EndRecording() && !state) { state = 1; Write1053Sci(SCIR_AICTRL3, 1); // Send VS1053 request to stop recording } /* See how many 16-bit words there are waiting in the VS1053 buffer */ wordsWaiting = Read1053Sci(SCIR_HDAT1); /* If user has requested stopping recording, and VS1053 has stopped recording, proceed to the next state.
VS1053 B O GG VORBIS E NCODER VSMPG HH /* Read twice SCIR_AICTRL3, then check bit Read1053Sci(SCIR_AICTRL3); if (!(Read1053Sci(SCIR_AICTRL3) & (1<<2))) /* Write last half of the last word only fputc(lastWord & 0xFF, outFP); } } /* if (wordsToRead < 256) */ } /* while (wordsWaiting >= ((state < 2) ? 256 2 of latter read. */ { if bit 2 is clear.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.5 Vox and Pause Operation Vox / Pause allows the user to temporarily pause recording either based on audio content or direct user control. (For Ogg Vorbis Encoder Profiles that support Vox / Pause operation, see Chapter 2.2.1.) Vox control allows the unit to record only when someone is actually speaking.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.5.
VS1053 B O GG VORBIS E NCODER VSMPG HH 2.6 Samplerate Considerations The Ogg Vorbis encoder cannot always work at exactly the right samplerate. To be exact, the samplerate is accurate only when the input clock is 12.288 MHz and the nominal samplerate of a profile is either 8000 Hz or 16000 Hz. In all other cases the samplerate can be calculated as follows.
VS1053 B O GG VORBIS E NCODER VSMPG HH 3 The Ogg Vorbis Format This chapter gives a brief introduction to the Ogg Vorbis format and presents recommendations for basic parameters when transcoding MP3 files or compressing CD content into Ogg Vorbis files on a PC. The intent is to give VLSI Solution’s customers information on how to create high-quality Ogg Vorbis content. Before using the information in this document, you should get the free Ogg Vorbis encoder “oggenc”, minimum version 1.0.
VS1053 B O GG VORBIS E NCODER VSMPG HH and song length, and while it makes it easier to stream files, CBR is not optimal for quality. When there is a difficult passage in music, there may not be enough bits available to encode audio flawlessly. Conversely, in passages that are easier to encode there may be bits left unused because the encoder didn’t need all the bits available in the bitstream.
VS1053 B O GG VORBIS E NCODER VSMPG HH 3.2 Compressing into Ogg Vorbis with a PC The whole process of getting Ogg Vorbis files looks roughly like this: • Preparation: Decode an MP3 / WMA / AAC etc file or preferably rip a CD to WAV format and make sure that you have “oggenc” (Chapter 3.2.1). • Compression to Ogg Vorbis (Chapters 3.2.2 and 3.2.3). • Optional post-processing with VorbisGain (Chapter 3.3). 3.2.
VS1053 B O GG VORBIS E NCODER VSMPG HH Graphical front-ends usually contain one or several CBR bit-rate slider(s) and a quality slider that usually goes from -1 to 10. CBR sliders should be deactivated, and the quality slider should be set to the “-q” value presented in the table. Rev. 1.
VS1053 B O GG VORBIS E NCODER VSMPG HH 3.2.3 Compressing Speech Speech requires different coding parameters than music. First, speech can usually be coded in mono, so all the following examples convert audio to mono. Also, to get smaller files, speech bandwidth can usually be suppressed without adversely affecting intelligibility. The following table shows the command needed to convert a speech file called file.
VS1053 B O GG VORBIS E NCODER VSMPG HH 3.3 Post-Processing with VorbisGain Although the original CD standard defines a reference loudness that should be used for CD recording, current CDs no longer follow that standard. Because of this unequal loudness of CDs, songs compressed from CDs may have wildly differing subjective loudness, a phenomenon that is known to most users of portable digital audio players.
VS1053 B O GG VORBIS E NCODER VSMPG HH 4 How to Load a Plugin 4.1 How to Load a .PLG File A plugin file (.plg) contains a data file that contains one unsigned 16-bit vector called plugin. The file is in an interleaved and RLE compressed format. An example of a plugin vector is: const unsigned short plugin[10] = { /* Compressed plugin */ 0x0007, 0x0001, 0x8260, 0x0006, 0x0002, 0x1234, 0x5678, 0x0006, 0x8004, 0xabcd, }; The vector is decoded as follows: 1. 2. 3. 4.
VS1053 B O GG VORBIS E NCODER VSMPG HH 4.2 How to Load an .IMG File The VS1053 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”.
VS1053 B O GG VORBIS E NCODER VSMPG HH 4.2.1 Example Microcontroller .IMG File Decoder /* This support function that writes one word through SCI is needed. */ void WriteVS10xxRegister(unsigned short addr, unsigned short value); #define #define #define #define TYPE_I TYPE_X TYPE_Y TYPE_E 0 1 2 3 /* Returns either 0xFFFF for error or image file start address.
VS1053 B O GG VORBIS E NCODER VSMPG HH 5 Building a Streaming System This chapter presents how to build a streaming system over the Internet, RF link or other media. SERVER Main CPU Ogg Vorbis CLIENT(S) Ogg Vorbis INTERNET RF LINK ETC Line in Main CPU Line out VS1053 Earphone out RAM buffer VS1053 Mic in Figure 5: Streaming system using VS1053b. Figure 5 presents an example system that uses a VS1053b for both encoding and decoding Ogg Vorbis audio.
VS1053 B O GG VORBIS E NCODER VSMPG HH 5.1 Sample Counter An 32-bit sample counter, added for v1.3, is designed to help streaming Ogg Vorbis files. It tells the absolute sample number that is currently recorded through the ADC when an Ogg Vorbis file is being recorded. The sample counter is located at the beginning of the X memory user area, at address 0x1800, and it can be read through SCI. The VS1053b Patches package has a similar counter.
VS1053 B O GG VORBIS E NCODER VSMPG HH 5.2 End-to-End Delay of a Streaming System For a rough end-to-end delay estimate of a streaming Ogg Vorbis system, the following formula can be used: d= 4096×nf ×b+4000 fs where • d is the result in seconds. • nf is bits 7:4 of SCI_AICTRL3, see Chapter 2.3.1. For this formula to work, you must set the bits to a non-zero value. • b = 1 if you do byte-aligned read operations as instructed in Chapter 2.3.3. Otherwise b = 2. • fs is the samplerate.
VS1053 B O GG VORBIS E NCODER VSMPG HH 5.4 Streaming Example Let’s take a streaming system that uses two VS1053b’s, both running at 12.288 MHz crystals, and using best possible quality: the 44.1 kHz stereo Music Profile, Quality 5. This is what you need to do on the encoder side: • Load and start the VS1053b Ogg Vorbis Encoder. • If you want to maintain synchronization for an indefinite time, send also the sample counter in your message packats. For how to read the sample counter, see Chapter 5.
VS1053 B O GG VORBIS E NCODER VSMPG HH 6 Latest Version Changes This chapter describes the most important changes to the Vorbis VS1053b Ogg Vorbis Encoder and this document. Version 1.70c, 2012-11-16 This is a documentation change only. Software is unchanged since v1.70. • Added a Chapter 5.4, Streaming Example. • Corrected values in Chapter 5.3, Playback Speed Adjustment, to correspond with values required by the VS1053b Patches package. Version 1.70b, 2011-06-29 This is a documentation change only.
VS1053 B O GG VORBIS E NCODER VSMPG HH 7 Contact Information VLSI Solution Oy Entrance G, 2nd floor Hermiankatu 8 FI-33720 Tampere FINLAND Fax: +358-3-3140-8288 Phone: +358-3-3140-8200 Email: sales@vlsi.fi URL: http://www.vlsi.fi/ For technical questions or suggestions regarding this application, please contact support@vlsi.fi. Rev. 1.
Adafruit VS1053 MP3/AAC/Ogg/MIDI/WAV Codec Breakout Tutorial Created by Bill Earl Last updated on 2014-05-16 04:15:17 PM EDT
Guide Contents Guide Contents 2 Overview 4 Assembly 7 Prepare the Headers 8 Position the Board 8 And Solder! 9 Getting Started - VS1053 Software 10 Simple Audio Player Wiring 11 Prepare the breadboard 12 Connect SPI and Reset 12 Connect the rest of the digital signals 12 Connect the Headphone Jack 13 Load some MP3 files 13 Simple Audio Player Sketch 14 For the Micro: 14 Audio Connections 16 MIDI Connections 19 Prepare the breadboard 19 Configure for MIDI operation 19 Co
Additional Control Signals: 24 Start/Stop Button (Momentary): 24 Electret Microphone Circuit: 25 A note about microphone circuits: 26 Recording Sketch: 27 Plug-Ins 27 To Record: 27 To Playback: 27 Library Reference 28 class Adafruit_VS1053_FilePlayer 28 Public Methods: 28 Public Member Variables: 28 class Adafruit_VS1053 28 public Methods: 28 Downloads and Links 31 Library: 31 Technical Information: 31 Schematics for v2 31 © Adafruit Industries https://learn.adafruit.
Overview Above: v1.0 codec board. Below: v2.0 codec board © Adafruit Industries https://learn.adafruit.
This breakout board is the ultimate companion for the VLSI VS1053B DSP codec chip. The VS1053 can decode a wide variety of audio formats such as MP3, AAC, Ogg Vorbis, WMA, MIDI, FLAC, WAV (PCM and ADPCM). It can also be used to record audio in both PCM (WAV) and compressed Ogg Vorbis. You can do all sorts of stuff with the audio as well such as adjusting bass, treble, and volume digitally. There are also 8 GPIO pins that can be used for stuff like lighting up small LEDs or reading buttons.
pulldowns, simply connect your button from the GPIO pin to 3.3V for an active-high connection. You'll likely want to play music from a microSD card so we added a holder onboard. And since we know so many of our customers use 5V microcontrollers like the Arduino, we made the interface pins all 5V compliant with level shifters so you can use the chip at 3V or 5V power/logic! The breakout board comes fully assembled and tested. All v1.
Assembly The board comes with all surface-mount components assembled and tested. For use on a breadboard, you will want to install the included header strips. This is a simple process and should only take a few minute Assembly is the same fo r bo th v1 and v2 breako uts, even if the bo ards lo o k a bit different! © Adafruit Industries https://learn.adafruit.
Prepare the Headers Cut the header strips to length if necessary and place the long-pins-down in the breadboard. Position the Board Place the breakout board over the header pins. © Adafruit Industries https://learn.adafruit.
And Solder! Solder every pin to assure good electrical contact. © Adafruit Industries https://learn.adafruit.
Getting Started - VS1053 Software To get started with the VS1053 breakout (any version) you will first need to download the Adafruit VS1053 Library: Download Adafruit VS1053 Library http://adafru.it/cDQ Copy the folder inside the zip file to the Libraries folder inside your Arduino Sketchbook folder and re-name it to Adafruit_VS1053 For more details on how to install Arduino libraries, check out our detailed tutorial using the link below: All About Arduino Libraries http://adafru.
Simple Audio Player Wiring The VS1053 can be configured as a simple audio player under control of the Arduino. The Arduino reads data from the on-board SD card, then plays it back through the CODEC via the SPI interface. These steps are identical fo r bo th v1 and v2 co dec breako uts, even if the bo ards lo o k a little bit different © Adafruit Industries https://learn.adafruit.
Prepare the breadboard Place the VS1053 breakout on the breadboard. Center it so that there is one row of holes on each side. Add the breakout friendly headphone jack and wire power and ground jumpers as shown.
Connect the Headphone Jack This step will be a little bit different depending on which version you have. If your breakout is v2 and has the round silver capacitors, add jumpers for: AGND -> Center 'gro und' Pin LOUT -> Left Pin ROUT -> Right Pin (these are in the corner in a row) If your breakout is v1, the pins will be labeled GBUF -> Center 'gro und' Pin LOUT -> Left Pin ROUT -> Right Pin For v1, do not use this wiring for powered speakers or a line-in connection to a computer/stereo.
Make sure you have a good quality SD card, some cheap SD cards won't work, causing confusion! Especially 'non-brand' knockoffs. Simple Audio Player Sketch Connect the Arduino to your computer with a USB cable and plug your headphones into the headphone jack. Select File->Examples->Adafruit_VS1053_Co dec->player_simple to load the example code. You should hear your MP3 files in the headphones. You can also run File->Examples->Adafruit_VS1053_Co dec->player_interrupts.
© Adafruit Industries https://learn.adafruit.
Audio Connections Both the VS1053 version 1 (shown above, does not have big round silver capacitors at the top) and the version 2 (has a v2 label, has two big round silver caps) can drive a pair of headphones directly. Just connect the LOUT and ROUT to the left and right pins of the headphone jack. The center pin should be connected to GBUF. © Adafruit Industries https://learn.adafruit.
Both v1 and v2 can also directly drive audio devices with differential inputs such as our 3.7 Watt Stereo Class D Amplifier. Connect LOUT and ROUT to the L+ and R+ pins of the amplifier. Connect L- and R- to the AGND pins. © Adafruit Industries https://learn.adafruit.
If yo u have a v1 breako ut, yo u can co nnect to po wered speakers/stereo BUT YOU MUST USE THE INCLUDED CAPACITORS! For audio devices requiring a 'line level' input, use the included capacitors. These are polarized electrolytic capacitors, so it matters which way you connect them. Connect the positive (longer) leads to the LOUT and ROUT pins, and the negative leads to the L & R pins of the headphone jack or L and R inputs of the audio device.
MIDI Connections With a few jumper connections, the board will boot up in MIDI mode that will read 'classic' 31250Kbaud MIDI data on a UART pin and act like a synth/drum machine - there are dozens of built-in drum and sample effects. Prepare the breadboard Place the VS1053 breakout on the breadboard. Center it so that there is one row of holes on each side. Add the breakout friendly headphone jack and wire power and ground jumpers as shown.
Midi Example Sketch Connect the Arduino to your computer with a USB cable and plug your headphones into the headphone jack. Select File->Examples->Adafruit_VS1053_Co dec>player_miditest to load the example code for MIDI operation.. You should hear a repeating series of ascending tones from the MIDI player. © Adafruit Industries https://learn.adafruit.
GPIO The VS1053 has 8 GPIO pins that can be read and written via the library. The player_gpiotest sketch demonstrates how to do this. Start with the basic wiring Use the Simple Audio Player Wiring from the link on the left. Add some LEDs Add a jumper from the ground bus on the left to the ground bus on the right of the breadboard. Then add some LEDs from the GPIO pins to ground. Be sure to connect the long lead (anode) to the GPOI pin and the short lead (cathode) to ground.
If you open the Serial Monitor, you can see the values that are written to and read from each GPIO pin. Note that the GPIO pins are NOT 5v safe. Do not connect them to voltages greater than 3.3v. © Adafruit Industries https://learn.adafruit.
Ogg Recorder (Nipper photo by Bevery & Pack - Creative Commons Share Alike) Recording with the VS1053 The record_ogg example sketch turns your VS1053 breakout into a recording device that generates OGG encoded files on the SD card in real-time. © Adafruit Industries https://learn.adafruit.
Wiring Wiring for the record_ogg sketch is as follows: Po wer and Gro und: VCC -> 5v GND -> GND Basic SPI connections: SCLK -> Arduino #13 MOSI -> Arduino #11 MISO -> Arduino #12 CS -> Arduino #10 Additional Control Signals: SDCS -> Arduino A0 XDCS -> Arduino #8 RST -> Arduino #9 DREQ -> Arduino A1 Start/Stop Button (Momentary): fro m Arduino #7 to GND © Adafruit Industries https://learn.adafruit.
Electret Microphone Circuit: The Microphone circuit is derived from the reference design shown in Figure 3 on Page 13 of the VS1053B Datasheet (http://adafru.it/clI). Note that the ground connections shown are to analog ground (AGND). © Adafruit Industries https://learn.adafruit.
A note about microphone circuits: © Adafruit Industries https://learn.adafruit.
Microphones, by their nature, are very sensitive devices. They are prone to picking up all sorts of noises (both electrical and acoustic) in addition to what you are trying to record. A microphone circuit built on a breadboard is not likely to sound good at all. For good sound, you will want to review the spec sheet recommendations and build this on a good quality circuit board. Recording Sketch: Connect the Arduino to your computer with a USB cable and plug your headphones into the headphone jack.
Library Reference class Adafruit_VS1053_FilePlayer The Adafruit_VS1053_FilePlayer class is derived from the Adafruit_VS1053 class and provides high level functions for playing files stored on the VS1053 breakout SC Card reader. Public Methods: Adafruit_VS1053_FilePlayer (uint8_t mo si, uint8_t miso , uint8_t clk, uint8_t rst, uint8_t cs, uint8_t dcs, uint8_t dreq, uint8_t cardCS) - Software SPI constructor. Uses Software SPI, so you must specify all SPI pins.
Adafruit_VS1053(uint8_t mo si, uint8_t miso , uint8_t clk, uint8_t rst, uint8_t cs, uint8_t dcs, uint8_t dreq) - Software SPI constructor - must specify all pins. Adafruit_VS1053(uint8_t rst, uint8_t cs, uint8_t dcs, uint8_t dreq) Hardware SPI constructor - assumes hardware SPI pins. uint8_t begin(vo id) - Initialize SPI communication and (hard) reset the chip. vo id reset(vo id) - Performs a hard reset of the chip. vo id so ftReset(vo id) - Attempts a soft reset of the chip.
uint16_t GPIO_digitalRead(vo id) - Read all 8 GPIO pins at once. bo o lean GPIO_digitalRead(uint8_t i) - Read a single GPIO pin. vo id GPIO_pinMo de(uint8_t i, uint8_t dir) - Set the Pin Mode (INPUT/OUTPUT) for a GPIO pin. bo o lean prepareReco rdOgg(char *plugin) - Initialize chip for OGG recording. vo id startReco rdOgg(bo o lean mic) - Start recording (mic = true for microphone input). vo id sto pReco rdOgg(vo id) - Stop the recording.
Downloads and Links Library: Adafruit VS1053 Library (http://adafru.it/clE) Technical Information: VS1053B (Codec chip) datasheet (http://adafru.it/clI) Details about the Ogg vorbis encoder/recorder (http://adafru.it/clJ) App note on connecting to analog outputs! (http://adafru.it/clK) Dimensions: 27.72mm / 1.09" x 58.08mm / 2.28" Schematics for v2 © Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2014-05-16 04:15:19 PM EDT Page 32 of 32