background image

PRELIMINARY

VS1063a Prog. Guide

6

WRITING USER APPLICATIONS THAT TAKE FULL CONTROL OVER VS1063A

6.2.1

Taking 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 reacti-
vation 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:

Interrupt vectors

Name

Address

Used

Default

Description

VEC_DAC

0x20

Yes

jmpi dac_int,(i6)+1

DAC

VEC_SCI

0x21

Yes

jmpi sci_int,(i6)+1

SCI

VEC_SDI

0x22

Yes

jmpi _sdi_int,(i6)+1

SDI

VEC_ADC

0x23

Y/N

1

jmpi modu_int,(i6)+1

ADC

VEC_TX

0x24

No

jmpi _empty_int,(i6)+1

UART TX

VEC_RX

0x25

Yes

jmpi rx_int,(i6)+1

UART RX

VEC_TIM0

0x26

No

jmpi _empty_int,(i6)+1

Timer 0

VEC_TIM1

0x27

No

jmpi _empty_int,(i6)+1

Timer 1

VEC_SRC

0x28

Y/N

2

jmpi src_int,(i6)+1

SampleRate Converter

VEC_SDM

0x29

Y/N

3

jmpi sdm_int,(i6)+1

Sigma Delta Modulator

1

Active in codec and encoding mode.

2

Active in encoding mode.

3

Active if PCM Mixer or AD Mixer is used.

To replace an interrupt vector, calculate

i

= 0

x

2

A

00000

E

+

a

×

0

x

40

, 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.3

VSIDE and Applications

VSIDE will get a VS1063a full control application example in Q3/2011.

Version: 0.40, 2011-09-02

18

Содержание VS1063a

Страница 1: ...ebugging 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 pro prietary low power DSP core VS_DSP4 ROM memories 16 KiB instruction RAM and upto 80 KiB data RAM for user applications run ning simultaneously with any built in decoder se...

Страница 2: ...st 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 dig ital volume control to an oversampling sigma delta DAC Decoding is controlled ...

Страница 3: ...ugin Call Conventions 12 5 2 3 Simple Example Audio Path Plugin 13 5 2 4 Disabling the Audio Path Plugin 14 5 2 5 VSIDE and Audio Path Plugins 14 5 3 Idle Hook Plugin 15 5 4 Interrupt Driven Plugin 15 6 Writing User Applications that Take Full Control over VS1063a 16 6 1 Application Memory Maps 16 6 1 1 Application Instruction Memory Map 32 bit words 16 6 1 2 Application X Data Memory Map 16 bit w...

Страница 4: ...oller Plugin Decoder 22 8 2 VS1063a Image Format 23 8 2 1 The IMG Format and VSIDE 23 8 2 2 Example VS1063a Microcontroller Boot Image Decoder 24 9 Latest Document Version Changes 25 10 Contact Information 26 List of Figures 1 Decoder data flow of VS1063a with the user plugin stage highlighted 11 Version 0 40 2011 09 02 4 ...

Страница 5: ...ions and VS1063a startup 2 Disclaimer 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 applica tions 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 ...

Страница 6: ...ression 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 e...

Страница 7: ..._HIGH p p Software SPI port Shift 8 bits in and out using a software SPI port unsigned char SpiTransfer unsigned char outdata unsigned char b 0 unsigned char indata 0 for b 0 b 8 b if outdata 0x80 Leftmost bit first OUT_SET_HIGH PIN_MOSI else OUT_SET_LOW PIN_MOSI outdata 1 Shift outdata bits left OUT_SET_HIGH PIN_SCK Clock high indata 1 Shift indata bits left if IN_IS_HIGH PIN_MISO indata 1 Set ri...

Страница 8: ...Data OUT_SET_LOW VS_XDCS Pull the VS10xx Data Chip Select line High define VsDeselectData OUT_SET_HIGH VS_XDCS void VsWriteRegister unsigned char reg unsigned int val OUT_SET_LOW PIN_XCS Control Chip Select Low SpiTransfer VS_WRITE_COMMAND WRITE command SpiTransfer reg Register number SpiTransfer unsigned char val 8 High Byte SpiTransfer unsigned char val 0xff Low Byte OUT_SET_HIGH PIN_XCS Control...

Страница 9: ... CONFIGURE_AS_INPUT PIN_MISO CONFIGURE_AS_OUTPUT PIN_MOSI CONFIGURE_AS_OUTPUT PIN_SCK CONFIGURE_AS_OUTPUT PIN_XCS OUT_SET_LOW PIN_SCK OUT_SET_HIGH PIN_XCS st VsReadRegister SCI_STATUS VsWriteRegister SCI_VOL 0x0a0a 4 2 The SDI SPI Bus Like SCI also SDI is an SPI bus However SDI is meant for simple unstructured bitstream transfer for e g MP3 files Below is a pseudocode example of how to send 32 byt...

Страница 10: ...ware 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 1 Plugin Memory Maps This chapter presents free memory maps for plugins All units are in words 5 1 1 Plugi...

Страница 11: ...arSpeakerLevel 0 earSpeakerLevel 0 ST_AMPLITUDE 0 SB_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 Figure 1 Decoder data flow of VS1063a with the user plugin...

Страница 12: ...unhandled values for mode should return n Symbol Value Description APPL_RESET 0 Reset all values n is samplerate APPL_AUDIO 1 Audio samples offered n is number of L R sample pairs APPL_W0 2 SCI_AICTRL0 has been written to n is register value APPL_W1 3 SCI_AICTRL1 has been written to n is register value APPL_W2 4 SCI_AICTRL2 has been written to n is register value APPL_W3 5 SCI_AICTRL3 has been wri...

Страница 13: ...ower volume main volume setting may be turned higher 5 2 3 Simple 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 auto u_int16 DbToLin register u_int16 dB s_int16 MyPlugin register s_int16 __i0 data register u_int16 __a1 mode regi...

Страница 14: ...ter u_int16 dB if dB 90 return 0 return dBTab dB 6 dB 6 5 2 4 Disabling the Audio Path Plugin 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 succi fient The application needs to write NULL to the pointer variable applAddr ASM convention _applAddr The type for applAddr is shown below extern s_in...

Страница 15: ...50 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 usin...

Страница 16: ...ay 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 1 Application Memory Maps This chapter presents free memory maps for application programs All units are in words 6 1 1 Application Instruction Memory Map 32 bit words Free instruction ...

Страница 17: ...rd 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 f...

Страница 18: ...2 jmpi src_int i6 1 SampleRate Converter VEC_SDM 0x29 Y N3 jmpi sdm_int i6 1 Sigma Delta Modulator 1 Active in codec and encoding mode 2 Active in encoding mode 3 Active if PCM Mixer or AD Mixer is used 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...

Страница 19: ...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 su...

Страница 20: ...es 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 wit...

Страница 21: ...234 0x5678 0x0006 0x8004 0xabcd The vector is decoded as follows 1 Read register address number addr and repeat number n 2 If n 0x8000U write the next word n times to register addr 3 Else write next n words to register addr 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 ...

Страница 22: ...gned short addr unsigned short value void LoadPlugin void int i 0 Execute fo reach word in plugin while i sizeof plugin sizeof plugin 0 unsigned short addr n val Get address and number of words in current segment addr plugin i n plugin i if n 0x8000U RLE run replicate n 0x7FFF samples n 0x7FFF val plugin i while n WriteVS10xxRegister addr val else if n 0x8000U Copy run copy n samples while n val p...

Страница 23: ...ot record is shown below VS1063a Boot Record from 1 to n last is always TYPE Execute Name Bytes Description TYPE 1 0 Instruction memory 1 X data memory 2 Y data memory 3 Execute L1 L0 2 LEN 256 L1 L0 A1 A0 2 ADDR 256 A1 A0 D1 D0 LEN DATA 256 D1 D0 repeat LEN 2 times The last boot record is always with TYPE Execute When an execute record is found ADDR is the start address of the application The VS1...

Страница 24: ... if fgetc fp P fgetc fp fgetc fp H return 0xFFFF while type fgetc fp 0 type 4 static const u_int16 offsets 3 0x8000U 0x0U 0x4000U u_int16 len addr Get length and address of the record len fgetc fp 8 len fgetc fp addr fgetc fp 8 addr fgetc fp If execute record return with start address if type TYPE_E return addr Map address to WRAMADDR register space if type TYPE_Y addr 0xE000 addr offsets type Set...

Страница 25: ...ANGES 9 Latest Document Version Changes This chapter describes the most important changes to this document Version 0 40 2011 09 02 Minor corrections Version 0 30 2011 05 20 First publication Still missing chapters ROM Functions VS1063a Startup Version 0 40 2011 09 02 25 ...

Страница 26: ...uide 10 CONTACT INFORMATION 10 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 0 40 2011 09 02 26 ...

Отзывы: