All information in this document is provided as-is without warranty. Features are
subject to change without notice. This document may contain mistakes and typing errors. Please contact VLSI if you suspect an error.
Revision History
Rev.DateAuthorDescription
0.12007-03-23PKPPreliminary version
0.112007-04-16PKPMinor adjustments
0.122007-06-28PKPAdditions for version 1.33 of developer tools
0.142007-06-28PKPVS1000B minor update
0.152008-06-30POjvskit1.34: lib and include merged
0.162009-07-06POjUSB register map fixed.
0.202011-10-04POjMore NF peripheral information.
Rev. 0.202011-10-04
Page 1(90)
Page 2
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
Who needs to read this document
This document describes the programming interface, register map and and integrated
peripherals of the VS1000. It’s primarily meant for those that wish to add to the functionality of the ROM code in VS1000 or design completely new software for the chip.
If you use the USB...
The example “Changing the USB descriptors” should be read by all vendors that have
USB functionality in their end-products. Although the ROM software is functional as is,
all such vendors should change the USB descriptors to identify the vendor and product
ID’s correctly.
Additionally, all vendors that ship devices conforming to the USB Mass Storage Class
specification should change the USB descriptors and create a unique serial number for
each device. Instructions on how to do this are given in the example.
VS1000B/C
VS1000B is an updated version of VS1000A. VS1000B has many small internal fixes
and some additions that remove some of the restrictions in VS1000A. It is mainly compatible with VS1000A, but code needs to be recompiled for VS1000B. This guide was
originally written for VS1000A, so it may not show all of the extra features in VS1000B.
VS1000C is another production test version of VS1000B with identical ROM.
VS1000D
VS1000D includes bug fixes, but is fully backwards-compatible with VS1000C. All software works without recompilation, so VS1000D can be used as a direct replacement.
The patches required for VS1000C are no longer necessary, which can save a bit of
code space.
The most important VS1000D changes:
• Code can be loaded and executed when in USB RAM disk mode without
detaching the device.
• Default 3V IO voltage setting reduced from 3.6 V to 3.3 V (control value 31 to 27).
• SCSI supports the full 32-bit block address (2048GB).
• BusyWait1() now waits 1 ms at 12 MHz clock.
• Time to enter low-power pause mode doubled.
• Ignores subdirectories in FAT12 disks.
• RAMDISK label changed to VS1000D_RAM to make it possible to detect VS1000D.
• USB descriptors, including device ID is the same as with VS1000B.
• Fixed-width Latin-1 font (7x8 pixels) and 8-bit bit-reverse table added to YROM.
VS1000 is a complete DSP system-on-chip (SoC) that can be used to implement a multitude of applications such as a single-chip Ogg Vorbis player. VS1000 contains a highperformance low-power DSP core VS_DSP4, NAND-FLASH interface, Full Speed USB
port, general purpose I/O pins, SPI, UART, as well as a high-quality variable-sample-rate
stereo DAC, and an earphone amplifier and a common voltage buffer.
Figure 1: VS1000 Block Diagram
Rev. 0.202011-10-04
Page 7(90)
Page 8
PKP
X memoryY memory
PROGRAM
CONTROL
PC
Program
memory
VS_DSP CORE
DATAPATH
arithmetic
registers
P register
ALU
X and Y
memory
ADDRESS
CALCULATION
address
registers
Y address
ALU
X address
ALU
control
registers
decode
logic
Peripheral
interface
PLL clock
generator
Peripheral
devices
Interrupt
arbitrator
Boot loader
Bus switch
VS1000 PROGRAMMER’S GUIDEVSMPG
2VS_DSP Basics
At VS1000’s core is the VS_DSP4 signal processor. It has a 16-bit Harward architecture
with three separate 16-bit address spaces: X and Y space for data and I space for
instructions (running code). All of these spaces have both ROM and RAM. In addition,
X and or Y spaces can occupy special function registers for peripheral devices.
Most of the features of the VS_DSP processor can be accessed by using standard C
language, without any specific VS_DSP knowledge. But if you need to develop really
powerful DSP algorithms, use the 40-bit datapath, control the pipeline and take the maximum out of the parallel X, Y and I buses, you need to study the VS_DSP architecture
and use assembly language.
The VS_DSP4 architecture manual is included in the VS1000-specific command-line
tools package (vskit140.zip), and also in VSIDE releases. Both packages are downloadable from VLSI Solution’s website (www.vlsi.fi).
Rev. 0.202011-10-04
Figure 2: VS_DSP General Architecture
Page 8(90)
Page 9
PKP
0000
3800
0400
0800
0c00
1000
1400
1800
1c00
2000
2400
2800
2c00
3000
3400
3c00
4000
mallocAreaX
System variables
(Vorbis heap)
audio buffer
mallocAreaY
IMDCT workspace
Y RAM (16−bit)
System Y
variables
User Y statics
Static user variables
IMDCT workspace
Vorbis
workspace
1A00
1B32
1BFF
1F85
X RAM (16−bit)
USB Receive
USB Send
4096 words
(8192 bytes)(8192 bytes)
4096 words
2K words (4K bytes)
I RAM (32−bit)
Interrupt vector (80 words)
USER CODE
1968 words = 7872 bytes
Reserved user static memory: 7872 bytes I + 2240 bytes X + 412 bytes Y, total: 10524 bytes
9216 words
(18432 bytes)
ing vorbis and disk cache,
when USB is connected)
(Vorbis heap when play−
Total stack space: 1024 bytes X + 1024 bytes Y, total: 2048 bytes (for user and system)
Total RAM space: 26624 bytes X + 32768 bytes Y + 8192 bytes I, total: 67584 bytes
stack space and function local variables
VS1000 PROGRAMMER’S GUIDEVSMPG
3VS1000 RAM Memory Map
Figure 3: VS1000B RAM layout
While playing Ogg Vorbis audio the memory areas available for user are 0x1fa0 to 0x23ff
Rev. 0.202011-10-04
(1120 words) in X data memory and 0x1b32 to 0x1bff (206 words) in Y data memory.
These areas are included in the default memory description file (mem_desc.vs1000), so
linker can allocate variables into those memory areas.
More memory can be used as temporary storage when audio is not being decoded.
Page 9(90)
Page 10
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
4VS1000 Integrated Peripherals
VS1000 contains several integrated peripherals. They are controlled by memory-mapped
special function registers. From the programmer’s point of view this means reading and
writing special memory locations. The peripheral registers in VS1000 are located in the
X address space.
VS1000 chip has the following integrated peripherals:
• 21 GPIO pins multiplexed with peripherals, each capable of generating an interrupt
• SPI port with master/slave operation and programmable Frame Sync
• UART port with programmable bit rate and framing error detection
• USB port with 12 Mbit/s signaling rate and 4 KiB of buffer memory
• Digital-to-Analog converter and integrated earphone driver
• Byte-wide Bus / Nand Flash controller with fast 32-byte buffer and ECC calculation
• 2 32-bit timers with shared master clock divider
• Interrupt controller, 11 interrupt sources
• 3 programmable linear regulators for generating analog, I/O and core voltages
• Internal oscillator for external crystal, can also use external oscillator
• Integrated Clock Generator with PLL and clock multiplier and low-speed modes
• Watchdog timer
The VS1000 has 76 KiB of program ROM and 8 KiB of program RAM. While the latter
might seem like a small amount, note that the ROM code contains many useful routines, interfaces and tables the RAM code can access. Many internal functions can be
replaced or augmented by hooking a handler vector of a ROM routine.
The amount of data RAM available varies depending on the application. If Vorbis playing
is not used, it can be over 50 KiB. For programs that do play Vorbis files, at least 2652
bytes can be used when Vorbis files are playing.
The complete peripheral documentation is in its own chapter.
Rev. 0.202011-10-04
Page 10(90)
Page 11
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
5VS1000 Register Map and Frequently Used Tables
VS1000 Peripheral Register Map
AddressRegisterFunction
0xC000SCI_SYSTEMSystem Controller control
0xC001SCI_STATUSSystem Controller control and status flags
0xC010GPIO0_MODEGPIO(0)/Peripheral(1) function for port 0 pins
0xC011GPIO1_MODEGPIO(0)/Peripheral(1) function for port 1 pins
0xC012DAC_VOLDigital-to-Analog Converter Volume
0xC013FREQCTLLInterpolator Frequency low part
0xC014FREQCTLHInterpolator Frequency high part
0xC015DAC_LEFTDAC Left Channel
0xC016DAC_RIGHTDAC Right Channel
0xC028UART_STATUSSerial Port Status
0xC029UART_DATASerial Port Data byte
0xC02AUART_DATAHSerial Port Data byte shifted 8 bits left
0xC02BUART_DIVSerial Port baudrate generator divider
0xC030TIMER_CONFIGTimer 0 and 1 Configuration
0xC031TIMER_ENABLETimer 0 and 1 Enable/Disable
0xC034TIMER_T0LLow 16 bits of Timer 0 reload value
0xC035TIMER_T0HHigh 16 bits of Timer 0 reload value
0xC036TIMER_T0CNTLLow 16 bits of Timer 0 current value
0xC037TIMER_T0CNTHHigh 16 bits of Timer 0 current value
0xC038TIMER_T1LLow 16 bits of Timer 1 reload value
0xC039TIMER_T1HHigh 16 bits of Timer 1 reload value
0xC03ATIMER_T1CNTLLow 16 bits of Timer 1 current value
0xC03BTIMER_T1CNTHHigh 16 bits of Timer 1 current value
0xC040GPIO0_DDRPort 0 Data Direction (“1”=output)
0xC041GPIO0_ODATAPort 0 Output Data
0xC042GPIO0_IDATAPort 0 Input Data (pin state)
0xC043GPIO0_INT_FALLFalling Edge Interrupt Enable
0xC044GPIO0_INT_RISERising Edge Interrupt Enable
0xC045GPIO0_INT_PENDInterrupt Pending
0xC046GPIO0_SET_MASKSet output bits high
0xC047GPIO0_CLEAR_MASKSet output bits low
0xC048GPIO0_BIT_CONFBit router engine 0 and 1 configuration
0xC049GPIO0_BIT_ENG0Bit router engine 0 data register
0xC04AGPIO0_BIT_ENG1Bit router engine 1 data register
Rev. 0.202011-10-04
Page 11(90)
Page 12
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
VS1000 Peripheral Register Map (continued)
AddressRegisterFunction
0xC050GPIO1_DDRPort 1 Data Direction (“1”=output)
0xC051GPIO1_ODATAPort 1 Output Data
0xC052GPIO1_IDATAPort 1 Input Data (pin state)
0xC053GPIO1_INT_FALLFalling Edge Interrupt Enable
0xC054GPIO1_INT_RISERising Edge Interrupt Enable
0xC055GPIO1_INT_PENDInterrupt Pending
0xC056GPIO1_SET_MASKSet output bits high
0xC057GPIO1_CLEAR_MASKSet output bits low
0xC058GPIO1_BIT_CONFBit router engine 0 and 1 configuration
0xC059GPIO1_BIT_ENG0Bit router engine 0 data register
0xC05AGPIO1_BIT_ENG1Bit router engine 1 data register
0xC060NFLSH_CTRLByte-wide Bus (Nand Flash) Controller Control
0xC061NFLSH_LPLCalculated Line Parity for 512-byte block
0xC062NFLSH_CP_LPHCalculated Column Parity for 512-byte block
0xC063NFLSH_DATABuffer Data read/write register
0xC064NFLSH_NFIFBuffer-to-Physical Interface Control
0xC065NFLSH_DSPIFBuffer-to-DSP Interface Control
0xC066NFLSH_ECC_CNTError Correction Code counter
0xC068SPI0_CONFIGSerial Peripheral Interface Configuration
0xC069SPI0_CLKCONFIGSPI Clock Configuration
0xC06ASPI0_STATUSSPI Status
0xC06BSPI0_DATASPI Data read/write register
0xC06CSPI0_FSYNCFrame Sync output bit image
0xC088USB_EP_SEND0EP0IN Transmittable Packet Info
0xC089USB_EP_SEND1EP1IN Transmittable Packet Info
0xC08AUSB_EP_SEND2EP2IN Transmittable Packet Info
0xC08BUSB_EP_SEND3EP3IN Transmittable Packet Info
0xC090USB_EP_ST0Flags for endpoints EP0IN and EP0OUT
0xC091USB_EP_ST1Flags for endpoints EP1IN and EP1OUT
0xC092USB_EP_ST2Flags for endpoints EP2IN and EP2OUT
0xC093USB_EP_ST3Flags for endpoints EP3IN and EP3OUT
Rev. 0.202011-10-04
Page 12(90)
Page 13
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
VS1000 Interrupt Sources
NameVectorSource
INTV_DAC0Digital to Analog Converter
INTV_SPI1Serial Peripheral Interface
INTV_USB2Universal Serial Bus
INTV_NFLSH3Byte-wide Bus (Nand Flash) Controller
INTV_TX4UART Transmit
INTV_RX5UART Receive
INTV_TIM06Timer 0 underflow
INTV_TIM17Timer 1 underflow
INTV_REGU8Input Voltage Monitor
INTV_GPIO09I/O Pin Controller 0
INTV_GPIO110I/O Pin Controller 1
VS1000 I/O Controller 0 pins and peripheral functions
GPIOIdentLQFP
Pin
GPIO0[0]NFDIO02Nand-flash IO0 / General-purpose IO Port 0, bit 0
GPIO0[1]NFDIO13Nand-flash IO1 / General-purpose IO Port 0, bit 1
GPIO0[2]NFDIO24Nand-flash IO2 / General-purpose IO Port 0, bit 2
GPIO0[3]NFDIO35Nand-flash IO3 / General-purpose IO Port 0, bit 3
GPIO0[4]NFDIO49Nand-flash IO4 / General-purpose IO Port 0, bit 4
GPIO0[5]NFDIO510Nand-flash IO5 / General-purpose IO Port 0, bit 5
GPIO0[6]NFDIO611Nand-flash IO6 / General-purpose IO Port 0, bit 6
GPIO0[7]NFDIO712Nand-flash IO7 / General-purpose IO Port 0, bit 7
GPIO0[8]NFRDY13Nand-flash READY / General-purpose IO Port 0, bit 8
GPIO0[9]NFRD14Nand-flash RD / General-purpose IO Port 0, bit 9
GPIO0[10] NFCE15Nand-flash CE / General-purpose IO Port 0, bit 10
GPIO0[11] NFWR20Nand-flash WR / General-purpose IO Port 0, bit 11
GPIO0[12] NFCLE16Nand-flash CLE / General-purpose IO Port 0, bit 12
GPIO0[13] NFALE17Nand-flash ALE / General-purpose IO Port 0, bit 13
GPIO0[14] CS221General-purpose IO Port 0, bit 14
Function
VS1000 I/O Controller 1 pins and peripheral functions
GPIOIdentLQFP
Pin
GPIO1[0]XCS22SPI XCS / General-Purpose I/O Port 1, bit 0
GPIO1[1]SCLK23SPI CLK / General-Purpose I/O Port 1, bit 1
GPIO1[2]SI24SPI MISO / General-Purpose I/O Port 1, bit 2
GPIO1[3]SO25SPI MOSI / General-Purpose I/O Port 1, bit 3
GPIO1[4]TX26UART TX / General-Purpose I/O Port 1, bit 4
GPIO1[5]RX27UART RX / General-Purpose I/O Port 1, bit 5
Rev. 0.202011-10-04
Function
Page 13(90)
Page 14
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
VS1000 Handler Vectors (Services)
AddressVector NameDefault HandlerRemark
0x0000IdleHookUserInterfaceIdleHookCPU idle
0x0002InitFileSystemFatInitFileSystemInit storage
0x0004OpenFileFatOpenFileOpen file
0x0006ReadFileFatReadFileRead file
0x0008SeekFatSeekSet file position
0x000aTellFatTellGet file position
0x000cReadDiskSectorMapperReadDiskSectorRead 512 bytes
0x000eStereoCopyOldStereoCopyOutput samples
0x0015Sine TestSinTestSine test
0x0016Memory TestMemTestMemory test 1
0x0017Memory TestMemTestsMemory tests
0x0018SetRateRealSetRateSet sample rate
0x001aPowerOffRealPowerOffClose and shutdown
0x001cPlayCurrentFileRealPlayCurrentFileStart playing file
0x001eUSBHandlerRealUSBHandlerUSB Task
0x002cMSCPacketFromPCRealMSCPacketFromPCMSC cmd or data
0x002eDecodeSetupPacketRealDecodeSetupPacketControl endpoint
0x0030ScsiTaskHandlerRealScsiTaskHandlerDisk task
0x0032LoadCheckRealLoadCheckClock adjust
0x0034UnsupportedFileDefUnsupportedFileUnknown format
Additional VS1000B Handler Vectors (Services)
0x0036KeyEventHandlerRealKeyEventHandlerPerform actions for
tosetDAC_VOL
and bassReg to init
bass/treble controls
Rev. 0.202011-10-04
Page 15(90)
Page 16
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
6Software Tools
Here is a list of the software tools that are necessary to compile and run the examples
of this programming guide. A more complete documentation of the software tools can
be found in the “Tools Manual”, available from VLSI. These command line tools are
available for UNIX and Windows. In addition to these files we recommend using GNU
Make to automatize the compilation process, but you can also compile by typing the
command lines separately in a shell or “MS-DOS Prompt”, or with the help of a suitable
batch file.
Free VSIDE integrated development tool is available and contains example projects for
VS1000.
The various tools can be downloaded from VLSI Solution’s Web Pages
See under Support / Software.
www.vlsi.fi
.
6.1vcc
The VLSI C Compiler. Creates a COFF object file from “C” language source file.
Example:
vcc-P130-O-fsmall-code-Ilib-oprogram.oprogram.c
6.2vslink
The linker. Creates a binary program file from multiple COFF object files.
The ROM monitor interface. Loads and runs binary program files using RS-232 cable between PC and VS10xx. Also provides standard input/output and file system for
debugging C code.
Example:
vs3emu-chipvs1000-s115200-lprogram.bine.cmd
6.4coff2spiboot
Creates bootable EEPROM image from a binary program file.
Rev. 0.202011-10-04
Page 16(90)
Page 17
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
Example:
coff2spiboot-x0x50program.bineeprom.img
6.5coff2nandboot
Creates a nand flash compatible boot record file from a binary program file.
Example:
coff2nandboot-t3-b8-s19-w50-x0x50led.binnand.rec
6.6makenandimage (required for VS1000A only)
Creates a prommable binary nand flash image from a nand flash compatible boot record
file.
Example:
makenandimagenand.recNANDFLSH.IMG
Rev. 0.202011-10-04
Page 17(90)
Page 18
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
7Examples
For more information and examples, check the VLSI Solution’s website, click Support,
then select Software. You can then find links for full VS1000 applications and smaller
VS1000 examples.
VS1000 evaluation boards also have source code available, so check out Support /
Evaluation Boards as well.
There are also VS1000-specific example projects for VSIDE.
See VSDSP Forum for general talk about VS1000 and other chips from
http://www.vsdsp-forum.com/
7.1Hello, World!
.
The first example of writing code for the VS1000 is the traditional “Hello, World!” example, which is compiled and linked. Then the RS-232 ROM monitor interface (vs3emu) is
used to load and execute the code.
The “hello.c” file is compiled using vcc with a command line such as:
vcc-P130-O-fsmall-code-Ilib-ohello.ohello.c
hello.c
is:
This creates a coff object file hello.o. The parameteres that were passed to vcc are:
-P130
-O
-fsmall-code
-ohello.o
-Ilibhello.c
Rev. 0.202011-10-04
Treats warning 130 (“can’t find prototype”) as an error.
Optimize
Use 16-bit code model (uses libc16 libraries)
Output file is hello.o
subdirectory “
input file
lib
” contains include files
Page 18(90)
Page 19
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
7.1.2Linking
Next the hello.o object is linked using the VS1000 memory map, VS1000 ROM content
addresses and the relevant VSDSP link-time libraries using a command such as:
This produces a loadable object file hello.bin using the parameters:
-k
-mmem_user
-ohello.bin
-Llib
-lc-ldev1000lib/c-spi.o
keep relocation information (good for debugging)
use memory areas specified in file
output file is
hello.bin
libraries can be found in subdirectory “
use library
libc.a
and
libdev1000.a
mem_user
lib
”
(in the -L directory)
the vsemu and SPI boot compatible C startup module (in subdirectory
lib
). It calls
main()
and returns to ROM code to a point after
initializations and SPI boot but before Nand Flash init+boot.
lib/rom1000.ohello.o
address information of the ROM code (in subdirectory
user compiled module
lib
)
7.1.3Loading
There are many ways to load runnable code to VS1000 chips. Code can be loaded
automatically during boot-up time from an SPI EEPROM or a NAND flash.
During program development it’s usually easiest to load the code using an RS-232
(“COM port”) emulator interface, which connects to the RX and TX pins of VS1000.
Note that a program booting from SPI and NAND FLASH may interfere with the loaded
program. You can disable SPI boot and erase the boot program part from NAND FLASH
to make certain. Leave the NAND FLASH ident, so the NAND FLASH can be used by
the ROM firmware and your program.
1
The PC side interface is invoked with:
vs3emu-chipvs1000-s115200-lhello.bin
which instructs the vs3emu interface to use the “vs1000” communication method and
default (COM1) port with line speed 115200 bit/s.
The emulator contacts the VS1000 by sending a special character to the COM port. This
is handled by the UART receive interrupt on the VS1000. If the VS1000 is running with
a 12 MHz crystal, interrupts are enabled and the core is running, it responds with:
This is easiest with a VS1000 Developer Board, but even the VS1000 Demonstration Board could
be used in this fashion by building a suitable RS-232 interface board. It would require connecting a
MAX3232 or equivalent buffer chip to the “RX” and “TX” pads on the Demonstration Board PCB. Power
for the MAX3232 could be taken from the JP1 expansion header.
Next the executing address is set to be 0x0050 (statically linked loading vector for main())
by command
>g0x50>eHello,World!
g0x50
and executed by commande. On the screen it should look like:
This final stage can be automated by writing the commands
g0x50
andeto file
e.cmd
and calling the emulator with the command line
vs3emu-chipvs1000-s115200-lhello.bine.cmd
The emulator can be exited by pressing Ctrl-C.
7.1.4Note
If your board has boot code in the Nand Flash, the Nand Flash boot code runs after
main() exits.
7.1.5Input and Output
This example uses the vs3emu interface to handle C standard I/O (
stdin,stdout
With it it’s possible to write messages to the user and read input from the PC keyboard.
Also it’s possible to open, read and write files in the PC. The library contains the elementary functions necessary for input and output. In this example, the library function
puts()
, which outputs a line of text and a linefeed to
stdout
, was used.
).
Since the memory capacity of the chip is limited, the more advanced and memory consuming input/output functions such as printf should not be used. When you need to print
out values of variables, it’s recomended to use a smaller special function for it. As an
example, here is a small function that outputs the value of a 16-bit unsigned integer as
a hexadecimal value:
(or any file input/output) in your code, a connection with
vs3emu is required. You should carefully remove any such code before porting the code
to be loaded via another method than vs3emu such as a boot flash or eeprom. This
could be done by surrounding the I/O code with
#ifdefDEBUG
and
#endif
pre-proces-
sor directives.
Rev. 0.202011-10-04
Page 21(90)
Page 22
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
7.2Making the LEDs blink
The example code below will blink the two LEDs that are connected to VS1000’s SI and
SO pins on the Developer Board and the Demonstration Board. Controlling the pins
directly requires switching the pin modes from Peripheral control to General Purpose IO
control and setting their Output Enable bits to “1”.
The SPI port pins and UART port pins are controlled by the same I/O controller, I/O
controller 1. When disabling peripheral control of the SPI pins, the UART pins (RX, TX)
must remain under peripheral control. Otherwise, the connection with vs3emu is lost.
For reference, here are the GPIO1 pin mappings of VS1000:
VS1000 I/O Controller 1 pins and peripheral functions
GPIOIdentLQFP
Function
Pin
GPIO1[0]XCS22SPI XCS / General-Purpose I/O Port 1, bit 0
GPIO1[1]SCLK23SPI CLK / General-Purpose I/O Port 1, bit 1
GPIO1[2]SI24SPI MISO / General-Purpose I/O Port 1, bit 2
GPIO1[3]SO25SPI MOSI / General-Purpose I/O Port 1, bit 3
GPIO1[4]TX26UART TX / General-Purpose I/O Port 1, bit 4
GPIO1[5]RX27UART RX / General-Purpose I/O Port 1, bit 5
Rev. 0.202011-10-04
Page 22(90)
Page 23
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
7.3Adjusting the Player User Interface
The ROM code implements a Vorbis player with a user interface that has 6 buttons:
• Power/Play/Pause
• Previous/Rewind
• Next/Fast Forward
• Volume -
• Volume +
• EarSpeaker (spatial processing) setting change
In addition to the 6-button interface the ROM contains alternative default key mappings
for a 5-button and 4-button user interfaces.
If these are not sufficient, there are two alternatives:
• Create a custom key → event mapping
• Take full control of the player
The VS1000 ROM function
17 pre-defined player control events, the 12 first are common with VS1000A.
ValueEventFunction
0ke_nullDo nothing
1ke_previousPlay Previous song
2ke_nextPlay Next song
3ke_rewindRewind
4ke_forwardFast Forward
5ke_volumeUpVolume Up
6ke_volumeDownVolume Down
7ke_earSpeakerSwitch EarSpeaker processing (4 settings)
8ke_earSpeakerToggleToggle EarSpeaker processing (2 settings)
9ke_randomToggleRandom Play on/off
10ke_randomToggleNewSongPlay random song
11ke_pauseTogglePause on/off
12ke_powerOffClose and power down
13ke_ff_fasterincrease play speed (needs ke_ff_off as release event)
14ke_ff_slowerdecrease play speed (needs ke_ff_off as release event)
15ke_ff_offback to normal play speed
16ke_volumeUp2increase volume by 1.0 dB
17ke_volumeDown2decrease volume by 1.0 dB
voidKeyEventHandler(enumkeyEventevent)
VS1000B Pre-defined Player Control Events
can handle
A
KeyMapping
and events. The structure is an array of pairs
structKeyMapping{
u_int16key;//KeyMaskenumkeyEventevent;//Event
}
Rev. 0.202011-10-04
structure controls the relationship between key-presses, long key-presses
Page 23(90)
Page 24
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
The following program demonstrates changing the key mapping:
Hooks are software jump vectors, that are linked into fixed positions in the VS1000 RAM.
Their function is essentially the same as for instance the interrupt vector of a 80x86 processor. For instance, when the player is playing music, it reads a disk sector (512 bytes)
of data by calling a function ReadDiskSector(u_int16 *buffer, u_int32 sector). For this
call, the linker generates a call to a fixed address 0x000c. In that address (which is in
RAM) is a jump instruction to the start address of the ROM function MapperReadDiskSector(), which retrieves the data from a logical NAND Flash mapper interface using
map->Read().
By replacing the jump location of the ReadDiskSector() hook vector, it is easy to replace the storage device, which contains the files the player plays. Only the service
that delivers a sectorful of data from a storage device is changed while rest of the ROM
functionality remains the same.
The image below demonstrates the disk data flow of VS1000:
Rev. 0.202011-10-04
Figure 4: Disk Data Flow
Below is an example of hookable disk read function that uses a previously declared
The above method is most convenient for preprogrammed storage devices. If you need
write access to your own storage device, you need to write control code for it yourself,
e.g. for downloading a disk image over a serial port.
7.4.1ReadDiskSector is for reading only
As the name suggests, the ReadDiskSector() hook is meant only for reading data. This
limits its usage to the “player” mode only (when the VS1000 is in player mode, it does
not write to the logical disk).
If you want to attach your own device to the USB bus as a mass storage device, you
need to write a mapper interface that has functions for reading and writing+erasing 512byte sectors. Then you need to write a function that publishes the interface with name
map
, initializes the USB handler (probably by calling
then calls
UsbHandler()
in a busy loop until the USB is detached.
InitUSB(USB_MASS_STORAGE)
) and
The complete example code is below. It uses 253 words of program RAM out of the
1968 words available for plugins.
Each USB device has a Vendor ID and a Product ID, which are 16-bit numbers that
the operating system uses for determining which device driver to load for the device.
Additionally most USB devices have a vendor name and model name strings that the
operating system can display to the user. All USB string descriptors are 16-bit Unicode
strings (UTF-16).
VS1000’s ROM code holds VLSI’s Vendor ID and Product ID. For prototyping you can
use an unused Vendor ID and Product ID, but when you ship products to customers, you
must use your own Vendor ID and Product ID. A Vendor ID can be obtained from the
USB Implementers Forum, Inc.’s web site,
To comply with USB Mass Storage Specification, each device that is shipped out to
customers should have a unique serial number in the USB descriptors. Windows uses
this serial number e.g. for storing device parameters in the system registry.
VS1000’s ROM is written so that it’s easy to change these descriptors without having to
touch the rest of the USB code. This example shows how you can change the Device
Descriptor, which holds the Vendor ID and Product ID, and the Vendor/Model/SerialNumber
string descriptors.
http://www.usb.org
.
USB.descriptorTable[6]InitUSBDescriptors
7.5.1Descriptor data format
Mostly because the USB has its roots in the 8-bit oriented PC (80x86) architecture, all
USB traffic is transmitted byte by byte. When values that have more than 8 bits, such as
16-bit integers or 32-bit integers, are transmitted, they are transmitted in the little-endian
(“Little End First”) format, where the least significant (last) byte of a multi-byte value is
sent first.
VS_DSP, however, is a natively 16-bit architecture that only handles 16-bit values. Thus
all data in VS_DSP must be stored as signed or unsigned 16 (or 32) bit values. To
maintain USB compatibility, care must be taken to transmit descriptors in the correct
byte order. In practice this means that descriptors should be stored in tables of byteswapped 16-bit unsigned integers as in the example below.
The serial number is a string of (at least) 12 characters from set {“0123456789ABCDEF”}.
All strings are stored in 16-bit Unicode format. The example code creates a new serial
number string descriptor
the
main()
device. You could generate it from e.g. the serial number of the storage memory your
product has. The first 4 characters (“1234” in the descriptor) could be fixed for a specific
program version etc.
function from
holds pointers to the descriptors. A system hook vector called
VS1000 supports loading boot-up code from an SPI EEPROM such as the 25LC640.
The ROM code checks the state of XCS pin during boot-up. If XCS is high, the code
attempts to read a boot record from the EEPROM using the SI, SO, SCLK and XCS pins.
In addition to the 16-bit addressing of SPI eeproms such as the 25LC640, the ROM also
supports 24-bit addressing of some larger EEPROMS (possibly up to 16 megabytes).
A program that is to be loaded using the SPI EEPROM must be linked with
ject module. The
but not from the nand flash.
The
coff2spiboot
output file with a command such as:
coff2spiboot-x0x50led.bineeprom.img
This reads the previously compiled program
age
eeprom.img
programmer.
A valid boot record starts with identifier 0x564C5349 (’V’,’L’,’S’,’I’) and contains blocks of
binary data that are to be stored at specified addresses. A boot record that is loaded
via the SPI bus must have an execution command as the last block. Description of the
block format is in the datasheet, if it should be needed for some special purpose.
8.0.2Using a VS1000 Developer Board as an eeprommer
Also a VS1000 Developer Board can be used to program the SPI EEPROM, using
the vs3emu file interface. The next pages contain an example program that reads the
eeprom.img
normally to a binary program
such as:
c-spi.o
tool can be used to create a bootable EEPROM image from the linker
, which can be programmed to an SPI EEPROM with an EEPROM
file and writes it to a 25LC640 EEPROM. The promming routine is compiled
module can also be used with running the code from vs3emu,
prommer.bin
led.bin
. It can be run with vs3emu with a command
and creates a binary eeprom im-
c-spi.o
ob-
vs3emu-chipvs1000-s115200-lprommer.bine.cmd
If the file
EEPROM and you should see output such as
First 512 bytes contain ID, start of the application and
the number of extra sectors to load
VS1000 PROGRAMMER’S GUIDEVSMPG
9Booting from NAND FLASH
If a nand flash chip is connected to the byte-wide bus interface of VS1000, it can
also be used for booting the VS1000. VS1000 supports natively most single-level cell,
single-chip-select NAND flashes such as the NAND128W3A2 from ST (small page) or
K9F2G08U0M from Samsung (large page).
With custom code (see MLCPlayer example from VS1000 software page) VS1000 can
also support various multi-level cell (MLC) memories with 2 kB block size. Larger page
sizes can be supported in special applications.
9.1Nand Flash startup sequence and structure
The nand flash boot is attempted after EEPROM boot. First the I/O voltages are set
according to the input state of GPIO0[7] pin. If SPI memory is not available, VS1000
attempts to read the first block of 512 bytes of the nand flash with 8 different access
methods, using the nand flash interface with only CS1 chip select. The access methods
cover small and large page flashes with 4, 5 or 6 address bytes.
Because different types of nand flash chips differ in the access methodology, using a
nand flash is somewhat more complicated than using an eeprom. To ensure proper
operation, a nand flash chip must be programmed with a valid VLSI ID record in the
beginning of block 0. VS1000 looks for the ID record and adjusts the nand access
parameters according to the ID record information.
If the VLSI boot id ’V”L”S”I’ (0x564C5349) is successfully read in the beginning of block
0, the ID record is considered valid. The next words of the ID record specify the overall
size, erasable block size, number of address bytes, block size and speed grade of the
nand flash chip in question in the format specified in the VS1000 datasheet.
The rest of the 512-byte block contain the start of the user boot code and the number of
extra sectors to load.
The first erasable block of a nand flash chip is reserved for boot data. The filesystem
that contains the songs to be played and is visible to the PC as a USB disk starts at a
further offset after the boot area and for security reasons is separate from the boot area.
Figure 5: Structure of the beginning of a Nand Flash in VS1000B
Rev. 0.202011-10-04
Page 36(90)
Page 37
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
9.2Preparing a nand flash image
A program that is to be loaded using the nand flash must be linked with
command line such as:
The above parameters are ok for the K9F2G08, which is installed in some of the Demonstration Boards shipped by VLSI. Others have NAND128W and for those a suitable
command line is
The resulting binary file
with a nand flash programmer.
coff2nandboot-t0-b5-s15-x0x50led.binNANDFLSH.IMG
NANDFLSH.IMG
can be prommed to the beginning of a nand flash
coff2nandboot
:
Rev. 0.202011-10-04
Page 37(90)
Page 38
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
9.3Using the VS1000 Demostration/Developer Board as a nand flash writer
Because it would be troublesome to remove a nand flash chip that is soldered to a PCB
for programming, the VS1000 contains a number of ways to update the flash contents.
The nand flash contents can be updated by
• programming the nand flash off-pcb using a prommer
• running a flasher program via the vs3emu emulator interface (requires RS-232)
• running a flasher program via an SPI EEPROM
• running a flasher program via the VS1000 USB mass storage backdoor
The last option is most convenient for players that don’t have RS-232 port, such as the
VS1000 Demonstration Board. When the VS1000 is switched to USB Mass Storage
mode by attaching the USB cable when GPIO0[6] is low, it creates a logical drive that is
presented to the USB host as a removable disk.
A special thing happens when the ROM software can’t detect a nand flash chip (by
reading the VLSI boot ID as explained earlier). In that case, the software creates a RAM
disk of a few kilobytes. This can be detected by the disk being empty and having a size of
only about 16 kilobytes. (The RAM disk also has the identifier signature “
but that is normally not shown by Windows.)
VLSIFATDISK
”
This feature can be used for initial programming of the nand flash since at the first bootup of a new VS1000 device with an empty nand flash, the VLSI ID is not yet programmed
into the nand flash and thus the RAM disk appears. Later on, when the nand flash is
programmed and its contents need to be updated, the nand flash detection can be
prevented by pulling CS1 low when powering up the VS1000. In the Demonstration
Board this can be done by shorting TP2 and CS1 pads on the Developer Board PCB.
When connected to the PC, the RAM disk appears and the short should be removed.
The user can now copy files to the RAM disk using Windows/Unix etc.
A special file named
USB cable is removed, without turning off power, the VS1000B loads and runs a boot
record from that file.
For updating the flash contents,
reads another file named
the beginning of the nand flash. When the VS1000 boots up the next time, with CS1
pulled high, it uses and boots up from the nand flash with the updated software.
The software tools package for VS1000 contains the above VS1000_B.RUN file. Its
source code is shown on the next page as an example of more complicated (and powerful) VS1000 programming that uses the integrated ROM code library.
The VS1000 can be interfaced easily to an external display controller using the SPI bus.
Since all LCD controllers don’t have an embedded character generator, the VS1000
includes a ROM font that can be used to draw alphanumeric characters and symbols.
The ROM font contains
• ASCII symbols 32...127
• Half-width katakana symbols
• Special symbols (play,pause,stop,speaker,usb,cabinet,...)
Additional symbols can be defined in RAM.
The low bytes of
width symbols:
u_int16fontPtrs[]
The high bytes of
bols:
u_int16fontData[]
u_int16fontData[]
contain the low end ASCII shapes and variable-
Figure 6: VS1000 variable-width symbols
contains the starting offsets of pixel data for each character.
contain katakana and fixed width special sym-
Figure 7: VS1000 fixed width symbols
For more information, see files
Also see optimized LCD functions in the VS1000 developer library (see dev1000.h) .
Rev. 0.202011-10-04
romfont.txt
and
display.c
in the Developer Toolkit.
Page 40(90)
Page 41
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
11Peripheral documentation
12VS1000 System Controller
12.1General
The System Controller controls various global aspects of VS1000 function such as the
system clock and voltages and I/O pin modes.
12.2Registers
The System Controller is accessed through 2 registers, SCI_SYSTEM and SCI_STATUS.
12.2.1SCI_SYSTEM: System Power and Clock Control
SCI_SYSTEM Bits
NameBitsDescription
SCISYSF_CLKDIV15Divide Clock by 2 (for 24 MHz xtal)
SCISYSF_AVDD14:10Analog and Usb Voltage setting 2.5V - 3.6V
SCISYSF_IOVDD9:5I/O Voltage setting 1.8V - 3.3V
SCISYSF_CVDD4:0Core Voltage setting 1.25V - 2.7V
SCI_SYSTEM controls the internal voltage regulator and clock divider of VS1000. Setting the clock divider while PLL is not used (clock multiplier = 1) makes the system run
at considerably slower clock rate, conserving the system power.
Setting bad voltage values can cause malfuntion and/or even physically harm the
device or, in case of IOVDD, even other devices attached to the I/O Pins.
The default values in reset are:
Default Regulator Output Voltages
NetDefault ValueDescription
AVDD2.6 VAnalog and Usb Voltage
IOVDD1.8 VI/O Voltage
CVDD2.2 VCore Voltage
The Core VDD is directly routed to the DSP core and peripheral logic. AVDD and IOVDD
are routed by the PCB, allowing PCB layout to generate fixed AVDD and IOVDD voltages
(for AVDD and IOVDD there are separate pins for regulator output and chip input).
Rev. 0.202011-10-04
Page 41(90)
Page 42
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
12.2.2USB powering
When USB is active, USB requires at least 3.5V, which is more than the default IOVDD
value, so the voltage for the USB pins is taken from AVDD output of the internal voltage
regulator.
12.2.3SCI_STATUS: System Flags
The SCI_STATUS register is the second System Controller register. It is used to control
and read the state of several system level peripherals.
SCI_STATUS Bits (r/w)
NameBitsDescription
SCISTF_SLOW_CLKMODE15Divide XTALI by 256
SCISTF_USB_DN_OUT14D- pin output state in GPIO mode
SCISTF_USB_DP_OUT13D+ pin output state in GPIO mode
SCISTF_USB_DDR12Drive D+/D- pins directly as GPIO
SCISTF_VCM_OVERLOAD11VCM pin overload, CBUF disconnected
SCISTF_VCM_DISABLE10Disable VCM protection
SCISTF_USB_DP9State of D+ pin
SCISTF_USB_DN8State of D- pin
SCISTF_USB_DIFF_ENA7Enable USB data input
SCISTF_USB_PULLUP_ENA6Activate 1.5kOhm D+ pull-up resistor
SCISTF_REGU_POWERLOW5Regulator input too low for good AVDD
SCISTF_REGU_POWERBUT4State of Power Button (“Play/Pause”) pin
SCISTF_ANADRV_PDOWN3Analog Output Driver power down control
SCISTF_ANA_PDOWN2Analog Core (bias) power down control
SCISTF_REGU_CLOCK1Clock in new regulator voltage values
SCISTF_REGU_SHUTDOWN0Regulator Shutdown control
12.2.4USB detection
USB detection and device attachment/detachment are handled using the System Controller. Actual USB data traffic is handled using the USB peripheral itself.
It is suggested that bot the D+ and D- pins have a 1 megaohm pull-up resistor on the
PCB. This makes both D+ and D- pins weakly bias to “1” state when the device is not
connected to a USB port. When the USB cable is attached, the 15 kilo-ohm pull-down
resistors of the host USB hub pull D+ and D- low, pulling the pins to “0” state. Thus
detecting SCISTF_USB_DN = 0 indicates USB cable connect.
Upon detecting the connection of the USB cable, software should switch to USB voltages, change the system clock to 48 MHz (XTALI=12.000MHz, Clock Multiplier 4.0x) and
wait for the clock to stabilize before setting SCISTF_USB_PULLUP_ENA high, which
activates the integrated 1.5 kilo-ohm pull-up resistor of D+, signaling the PC to start
enumeration of the USB device.
Rev. 0.202011-10-04
Page 42(90)
Page 43
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
12.3Conserving Power
Three main factors affect the power requirement of any CMOS device are clock frequency, voltage, and leakage. Of these, clock frequency has the greatest effect to power
consumption.
The Clock frequency of VS1000 is controlled by
• The XTALI input (crystal oscillator)
• The System Controller
• The PLL (Phase Locked Loop) Controller (Clock multiplier)
The System Controller’s role in clock control is providing two clock dividers between the
crystal oscillator output and the analog block and the PLL controller. First there is a
divide-by-2 block, which is controlled by SCISTF_SLOW_CLKMODE. After that there is
a divide-by-256 block, which is controlled by SCISYSF_CLKDIV.
The divide-by-2 block is normally used when there is a 24 MHz crystal connected to the
XTALI/XTALO pins (normally a 12 MHz crystal is used). Setting SCISTF_SLOW_CLKMODE affects all system frequencies, including the PLL, but it does not prohibit using
PLL.
It should be noted that the analog block requires 12 MHz from System Controller for
proper performance.
The divide-by-256 block is used to considerably cut down power consumption. This is
especially useful when some basic operation is needed (such as the capability to recover
from USB suspend or resume after low-power PAUSE mode) but battery life needs to
be extended.
The PLL must not be used when divide-by-256 is active. The PLL tries and fails to lock
to a frequency below PLL minimum. Switch off PLL (set 1 x clock multiplier) before
setting SCISYSF_CLKDIV.
If divide-by-256 is activated without first switching the analog drivers off, the DAC sigmadelta modulator noise (which is part of normal sigma-delta operation) drops down to audible frequencies, which is undesired. To overcome this, set SCISTF_ANADRV_PDOWN
before activating SCISYSF_CLKDIV. You should also write 0 to DAC_LEFT DAC_RIGHT
to further diminish digital noise and power consumption. Remember to restore the values before resuming playback.
If playback will resume directly after recovering from the power down state, it is not
recommended to set SCISTF_ANA_PDOWN since restoring the bias voltages of the
analog block can result in a power-up pop sound. If that is not relevant (such as in a
USB suspend condition,) SCISTF_ANA_PDOWN should be asserted to further minimize power consumption. Also setting the AVDD, DVDD and CVDD to a lower level will
diminish power consumption.
Rev. 0.202011-10-04
Page 43(90)
Page 44
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
The divide-by-2 and divide-by-256 blocks can be active at the same time, resulting in a
master clock that is divided by 512. With the standard 12 MHz crystal, this results in a
system clock of just above 23 kHz (23437.5 Hz).
12.4I/O Pin Routing
The System Controller controls the I/O pins of the device, routing signals to/from the
peripherals such as a serial port or GPIO controller.
GPIOn_MODE Bits
NameBitsDescription
periph/gpioX15:0bit vector; 1=peripheral 0=GPIO
GPIO0_MODE and GPIO1_MODE control output signal routing for the I/O pins. Most
pins are multiplexed between general purpose input/output and a peripheral function.
Pins are controlled by peripheral functions by default. Writing “0” to a bit in GPIOn_MODE
enables direct control over the pin.
Regardless of GPIOn_MODE register value, the input data (1/0 state of pin) can always
be read from the GPIOn_IDATA register (See section: Interruptable General Purpose
IO).
Switching a pin to GPIO mode can be used to disable data flow from a pin to a peripheral
function. The following peripheral input signal values are set when the corresponding
pin is in GPIO mode:
Peripheral Function Input Signal Values When pin is in GPIO Mode
The ROM code in VS1000 has the following usage for the System Controller:
At boot-up time, if pin D7 (pin number 12 in LQFP package) is pulled high, the ROM
software raises IOVDD from 1.8V to 3.3V. If it is pulled low, IOVDD remains at 1.8V. The
pin should not be left floating.
The default core voltage has been raised to 2.2V in VS1000B.
The ROM code expects a 12.000 MHz crystal input.
Rev. 0.202011-10-04
Page 44(90)
Page 45
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
13PLL controller v1.0 2006-05-10
13.1General
The Phase-Locked Loop (PLL) controller is used to generate clock frequencies that are
higher than the incoming (crystal-based) clock frequency. The PLL output is used by the
CPU core and some peripherals.
Configurable features include:
• VCO Enable/Disable
• Select VCO or input clock to be output clock
• Route VCO frequency to output pin
• Select PLL clock multiplier
13.2DAC Interpolator control
The DAC interpolator frequency control and PLL controller are controlled using the
same register pair FREQCTLH and FREQCTLL. Output sample rate is derived from the
rollover frequency of a 20-bit interpolator accumulator. Its accumulation rate is specified
by ifreq.
The maximum value for ifreq is 0x80000. Note that the DAC (and thus also the interpolator) clock is not controlled by the PLL (see “VS1000 System Controller” and “Overview
of VS1000 Clocking” ).
13.3Registers
Register map is shown in the next table.
13.3.1Interpolator Rate (low part)
FREQCTLL bits
NameBitsDescription
ifreq[15:0]15:0Bits 15..0 of the interpolator accumulation rate
Rev. 0.202011-10-04
Page 45(90)
Page 46
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
13.3.2Interpolator Rate (high part) and PLL control
FREQCTLH bits
NameBitsDescription
pll-lock-read130=lock failed since last test
pll-lock-test121:Sets pll-lock-read to 1 to start lock test
vco-out-ena11Route VCO to GPIO pin (VS1000:second cs
pin)
use-pll91:System clock is VCO / 0:System clock is inclk
pll-in-divide8divide inclk by 2 (for 1.5, 2.5 or 3.5 x clk)
pll-ratectl7:4PLL rate control
ifreq[19:16]3:0Bits 19..16 of the interpolator accumulation rate
For comprehensive reference on the function of the clock routing bits, see section
“Overview of VS1000 Clocking” below.
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 “Phase-Locked 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. the comparison phase difference remains virtually zero, the
PLL is said to be “in lock”. This means that the output frequency of the VCO is stable
and reliable.
The PLL locked status can be checked by generating a high-active pulse (writing first “1”
, then “0”) to pll-lock-test and reading pll-lock-read. Pll-lock-read is set to “1” along with
the high level of pll-lock-test and to “0” whenever the PLL falls out of lock. So if the “1”
remains in pll-lock-read, PLL is in sync.
The PLL controller gets its input clock from the System Controller and its operation
optimized for frequencies around 12..13 MHz. If you activate clock dividers in the System
Controller to get a slow master clock, you should turn the PLL off before (also switch off
analog before setting a clock of less than 10 MHz).
Note that USB requires 48.0 MHz for packet sending/receiving.
It’s recommended to change the PLL rate in small steps and wait for the PLL to stabilize
after each change. For diagnostic purposes, the PLL clock output (VCO) can be routed
to an I/O pin so it can be scanned with an oscilloscope.
Bits [7:4] (pll-ratectl) control PLL multiplication rate. PLL multiplier is (pll-ratectl + 1).
When pll-ratectl is 0, the VCO is powered down and output clock is forced to be input
clock (same as use-pll = 0).
Rev. 0.202011-10-04
Page 46(90)
Page 47
PKP
21
0
21
0
1
0
1
0
Analog BlockXTALI
SCI_SYSTEM[15]
256
FREQCTLH[8]
Multiplier
FREQCTLH[7:4] FREQCTLH[9]
4
CLKI
SCI_STATUS[15]
(should be
12..13 MHz
when playing)
To Core
VS1000 PROGRAMMER’S GUIDEVSMPG
13.4Overview of VS1000 Clocking
Below is a diagram showing the basic layout of the clock signal paths in VS1000:
Figure 8: VS1000 Clocking
With a 12.0000 megahertz crystal, the following core clock speeds are within limits:
Core Frequency CalculationXTALIN=12.000 MHz
Register ValuesResult
Registers:
SCI_SYSTEM[15]XTALI divide by 2
SCI_STATUS[15]XTALI divide by 256
FREQCTLH[9]Use PLL
FREQCTLH[8]Divide PLL input clock by 2
FREQCTLH[7:4]PLL rate control
SCI_SYSTEM[15]
SCI_STATUS[15]
FREQCTLH[9]
FREQCTLH[8]
FREQCTLH[7:4]
110000000.02344 MHz (23.438 kHz) (Lower CVDD possible)
010000000.04688 MHz
100000006 MHz
0000000012 MHz
0011001018 MHz
0010000124 MHz
0011010030 MHz
0010001036 MHz
0011011042 MHz
0010001148 MHz (required by USB, maximum used by ROM code)
0011100054 MHz
0010010060 MHz (Possible with high CVDD but not recommended)
Rev. 0.202011-10-04
Page 47(90)
Page 48
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
Note that higher frequencies have higher CVDD requirements and frequencies above
54 MHz are not recommended for production use.
13.5VS1000 ROM code usage
The ROM code in VS1000 has the following usage for PLL:
The clock rate is selected to be 12 MHz by default, 48 MHz when USB is connected
and variable between 12 and 42 MHz when Ogg Vorbis is playing. DAC rate is set to
44100 Hz when in the USB audio mode. When Vorbis is playing, the sample rate is set
to the sample rate specified in the Ogg file.
Rev. 0.202011-10-04
Page 48(90)
Page 49
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
14Interruptable General Purpose IO (VS1000) v1.0 2002-04-23
14.1General
This chapter describes the interrupt-capable 16-bit general-purpose I/O block for VS_DSP.
Note that in VS1000, pin function is partly handled also by the System Controller:
GPIOn_MODE register bits control whether output data for a GPIO pin is taken from
a peripheral function (mode=“1”) or the GPIO controller (mode=“0”).
6w0SET_MASKData set (→ 1) mask
7w0CLEAR_MASKData clear (→ 0) mask
8r/w0BIT_CONFBit engine config 0 and 1
9r/w0BIT_ENG0Bit engine 0 read/write
10r/w0BIT_ENG1Bit engine 1 read/write
14.2.1Data Direction GPIOx_DDR
The data direction register (DDR) configures the directions of each of the 16 I/O pins. A
bit set to 1 in the DDR turns the corresponding I/O pin to output mode, while a bit set
to 0 sets the pin to input mode. The register is set to all zeros in reset, i.e. all pins are
inputs by default. The current state of the DDR can also be read.
14.2.2Output Data GPIOx_ODATA
A write sets the data register value. Change in bits that are configured as outputs are
reflected in the outputs. A read returns the state of data register value.
Note: configuring a pin as input should not reset the state of the corresponding data
register bit. If the data register is first written 0xffff and then all pins are configured as
outputs by writing 0xffff to DDR, all outputs should go to the high state.
Rev. 0.202011-10-04
Page 49(90)
Page 50
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
This operation enables free selection of polarity for outputs, e.g. after reset a pull-up
keeps a control line high, the data register bit is set to 1 and after this the DDR bit is set
to 1 enabling the output.
When a data register bit is set to 0, it is easy to use the I/O pin as open-drain-style
output by changing the direction: as input the line state is 1 by a pull-up, as output the
line is pulled low by the driver.
Possible delays must be documented.
14.2.3Input Data GPIOx_IDATA
The actual logical levels of the I/O pins are seen in the input data register. Possible
delays must be documented.
If a bit the falling edge interrupt enable register (INT_FALL) is set to 1, a falling edge in
the corresponding pin (even when configured as output) will set the corresponding bit in
the interrupt pending source register (INT_PEND).
14.2.5Rising Edge Interrupt Enable GPIOx_INT_RISE
If a bit the rising edge interrupt enable register (INT_RISE) is set to 1, a rising edge in
the corresponding pin (even when configured as output) will set the corresponding bit in
the interrupt pending source register (INT_PEND).
14.2.6Interrupt Pending Source GPIOx_INT_PEND
If any of the bits in the interrupt pending source register (INT_PEND) are set, an interrupt
request is generated. Bits in INT_PEND can be cleared by writing a 1-bit to the bit that
is to be cleared.
Note: the interrupt request will remain asserted until all INT_PEND bits are cleared.
14.2.7Data Set Mask GPIOx_SET_MASK
A bit mask is written to the data set mask register. All bits that are set in the mask also
set the corresponding bit in the data output register. Other bits retain their old values.
I.e. a logical-OR operation is performed between the data output register old value and
the mask and the result is written to the data output register.
Rev. 0.202011-10-04
Page 50(90)
Page 51
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
14.2.8Data Clear Mask GPIOx_CLEAR_MASK
A bit mask is written to the data clear mask register. All bits that are set in the mask
clear the corresponding bit in the data output register. Other bits retain their old values.
I.e. a logical-AND operation is performed between the data output register old value and
the mask’s inverse and the result is written to the data output register.
14.2.9Bit Engine Config GPIOx_BIT_CONF
The bit engine config register (BIT_CONF) selects a mapping between an I/O bit and a
data output/input register bit for each of the bit engine registers.
GPIOx_BIT_CONF Bits
NameBitsDescription
GPIO_BE_DAT115:12Data bit selection (0..15) for bit engine 1
GPIO_BE_IO111:8I/O bit selection (0..15) for bit engine 1
GPIO_BE_DAT07:4Data bit selection (0..15) for bit engine 0
GPIO_BE_IO03:0I/O bit selection (0..15) for bit engine 0
14.2.10Bit Engine 0 Read/Write GPIOx_BIT_ENG0
When writing a value to the bit engine 0 register, the data bit specified in the configuration register is copied to the data output register bit specified in the same register.
When reading a value from the bit engine 0 register, the data input register bit specified
in the configuration register is copied to the data bit specified in the same register, other
bits read out as 0.
14.2.11Bit Engine 1 Read/Write GPIOx_BIT_ENG1
GPIOx_BIT_ENG1 works just like GPIOx_BIT_ENG0.
Rev. 0.202011-10-04
Page 51(90)
Page 52
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
14.3VS1000 GPIO Pin Mappings
VS1000 I/O Controller 0 pins and peripheral functions
GPIOIdentLQFP
Pin
GPIO0[0]NFDIO02Nand-flash IO0 / General-purpose IO Port 0, bit 0
GPIO0[1]NFDIO13Nand-flash IO1 / General-purpose IO Port 0, bit 1
GPIO0[2]NFDIO24Nand-flash IO2 / General-purpose IO Port 0, bit 2
GPIO0[3]NFDIO35Nand-flash IO3 / General-purpose IO Port 0, bit 3
GPIO0[4]NFDIO49Nand-flash IO4 / General-purpose IO Port 0, bit 4
GPIO0[5]NFDIO510Nand-flash IO5 / General-purpose IO Port 0, bit 5
GPIO0[6]NFDIO611Nand-flash IO6 / General-purpose IO Port 0, bit 6
GPIO0[7]NFDIO712Nand-flash IO7 / General-purpose IO Port 0, bit 7
GPIO0[8]NFRDY13Nand-flash READY / General-purpose IO Port 0, bit 8
GPIO0[9]NFRD14Nand-flash RD / General-purpose IO Port 0, bit 9
GPIO0[10] NFCE15Nand-flash CE / General-purpose IO Port 0, bit 10
GPIO0[11] NFWR20Nand-flash WR / General-purpose IO Port 0, bit 11
GPIO0[12] NFCLE16Nand-flash CLE / General-purpose IO Port 0, bit 12
GPIO0[13] NFALE17Nand-flash ALE / General-purpose IO Port 0, bit 13
GPIO0[14] CS221General-purpose IO Port 0, bit 14
Function
VS1000 I/O Controller 1 pins and peripheral functions
GPIOIdentLQFP
Pin
GPIO1[0]XCS22SPI XCS / General-Purpose I/O Port 1, bit 0
GPIO1[1]SCLK23SPI CLK / General-Purpose I/O Port 1, bit 1
GPIO1[2]SI24SPI MISO / General-Purpose I/O Port 1, bit 2
GPIO1[3]SO25SPI MOSI / General-Purpose I/O Port 1, bit 3
GPIO1[4]TX26UART TX / General-Purpose I/O Port 1, bit 4
GPIO1[5]RX27UART RX / General-Purpose I/O Port 1, bit 5
Function
14.4VS1000 ROM code usage
The ROM code in VS1000 has the following usage for GPIO pins:
NFDIO[0:7] (GPIO0[0:7]) are used as the data bus for NAND-FLASH communication,
NFRDY, NFRD, NFCE, NFWR, NFCLE, and NFALE are used as NAND-FLASH control
signals. NFCE, NFCLE, and NFALE are normal GPIO pins, the rest are controlled by
the NAND-FLASH interface peripheral.
Additionally GPIO0[0:4] are used for buttons in addition to the power button (see the
example schematic from the datasheet), and GPIO[6] is used to select between Mass
Storage / Audio Mode when USB is being attached, and GPIO[7] sets the desired IO
voltage at boot time.
GPIO0[14] is not used by the ROM code, so it can for example be used to add a serial
Rev. 0.202011-10-04
Page 52(90)
Page 53
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
display to SPI pins or a parallel display to NFDIO[0:7].
XCS, SCLK, SI, and SO (GPIO1[0:4]) are used for SPI EEPROM boot, if XCS is high
during power-on. During play mode GPIO1[2] and GPIO1[3] are used for play/pause
and random play indication.
TX and RX are normally used for the serial debugging connection.
Rev. 0.202011-10-04
Page 53(90)
Page 54
PKP
Enable
Reg 0
IRQ Source 0
Int
Origin 0
Global Enable Write
Global Disable Write
upint
Vector
Generation
and
Interrrupt
Request
Logic
5Int_vector
ack
IRQ Source 31
Enable
Reg 31
Int
origin 31
Global
Intr
Enable
VS1000 PROGRAMMER’S GUIDEVSMPG
15Interrupt Controller v1.0 2002-04-23
The interrupt controller is used to forward interrupt requests from peripherals to VSDSP.
The 32 interrupt sources are vectorized, i.e. the VS_DSP core jumps to a different
address according to the 5-bit interrupt vector value. There are three levels of priority
for simulteneous requests and a global disable available for all of the sources.
For an interrupt handler written in C, an assembly language stub that re-enables interrupts before RETI, should be written. The assembly language stub should call the C
language handler routine.
6r0VECTOR[4:0]Interrupt Vector
7r/w0ENCOUNT[2:0]Interrupt Enable Counter
8w0GLOB_DIS[-]Interrupt Global Disable
9w0GLOB_EN[-]Interrupt Global Enable
Page 54(90)
Page 55
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
• Enable registers, which contain enable/disable bits for each interrupt source. Bit
pairs configure the interrupt priority and disable.
• Origin registers, which contain the source flags for each interrupt. A request from
an interrupt source sets the corresponding bit. A bit is automatically reset when a
request for the source is generated.
• Enable counter register, which contains the value of the General Interrupt Enable
counter, and two registers for increasing and decreasing the value.
15.1.1Enable INT_ENABLE[L/H][0/1]
Interrupt enable registers selectively masks interrupt sources. Enable registers 0 contain
sources 0..15 and enable registers 1 contain sources 16..31. Each source has two
enable bits: one in the enable low and one in the enable high register. If both bits are
zero, the corresponding interrupt source is not enabled, otherwise the bits select the
interrupt priority.
Priorities only matter when the interrupt controller decides which interrupt to generate
for the core next. This happens whenever two interrupt sources request interrupts at the
same time, or when interrupts become enabled after an interrupt handler routine or part
of code where the interrupts have been disabled.
15.1.2Origin INT_ORIGIN[0/1]
If an interrupt source requests an interrupt, the corresponding bit in the interrupt origin register (ORIGIN0 or ORIGIN1) will be set to ’1’. If an interrupt source is enabled
(using ENABLE registers), the interrupt controller generates an interrupt request signal
for VSDSP with the corresponding vector value. The bit in the origin registers is reset
automatically after the interrupt is requested.
If the source is not enabled, the processor can read the origin register state and perform
any necessary actions without using interrupt generation, i.e. polling of the interrupt
sources is also possible. The bits in the interrupt origin registers can be cleared by
writing ’1’ to them.
A read from the interrupt origin register returns the register state.
A write to the interrupt origin register clears bits in the interrupt origin register. All ’1’bits in the written value cause the corresponding bits in the interrupt origin register to
be cleared. All zero-bits cause the corresponding bits in the interrupt origin register to
Rev. 0.202011-10-04
Page 55(90)
Page 56
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
keep their state. For example writing a value 0x00ff will clear the lowest eight bits in the
interrupt origin register, while leaving the upper bits as-is.
15.1.3Vector INT_VECTOR
The last generated vector value can be read from the vector register.
15.1.4Enable Counter INT_ENCOUNT
The global interrupt enable/disable is used to control whether an interrupt request is sent
to the processor or not. Whenever this 3-bit counter value is non-zero, interrupt requests
are not forwarded to VSDSP. The counter is increased by one whenever the interrupt
controller generates an interrupt request for VSDSP, thus disabling further interrupts.
When read, the enable counter register returns the counter value.
Don’t write directly to INT_ENCOUNT. Use INT_GLOB_DIS and INT_GLOB_EN to manipulate the value of this register.
15.1.5Global Disable INT_GLOB_DIS
A write (of any value) to global disable register increases the global interrupt enable/disable
counter by one. If the counter is zero, interrupt signal generation is enabled. When the
interrupt arbitrator generates an interrupt request for VS_DSP core, it automatically increases the counter. The user must write to the global enable register (once) to enable
interrupts.
If an interrupt is generated in the same cycle as a write to global disable register, the
interrupt enable counter is increased by two.
15.1.6Global Enable INT_GLOB_EN
A write (of any value) to global enable register decreases the global interrupt enable/disable
counter by one. If the counter is zero, interrupt generation is enabled.
The user must write to this register once in the end of the interrupt handler to enable
further interrupts. This should be done in assembly language.
Rev. 0.202011-10-04
Page 56(90)
Page 57
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
15.2VS1000 Interrupt Sources
VS1000 Interrupt Sources
NameVectorSource
INTV_DAC0Digital to Analog Converter
INTV_SPI1Serial Peripheral Interface
INTV_USB2Universal Serial Bus
INTV_NFLSH3Byte-wide Bus (Nand Flash) Controller
INTV_TX4UART Transmit
INTV_RX5UART Receive
INTV_TIM06Timer 0 underflow
INTV_TIM17Timer 1 underflow
INTV_REGU8Input Voltage Monitor
INTV_GPIO09I/O Pin Controller 0
INTV_GPIO110I/O Pin Controller 1
15.3VS1000 ROM code usage
The ROM code in VS1000 has the following usage for interrupts:
DAC interrupt handles feeding of samples from audio FIFO to DAC registers.
UART RX interrupt is used for starting the ROM monitor. If you perform stdio operations in your program, you should disable RX interrupt during at least fread() to prevent
monitor to be erroneously triggered.
Timer 0 interrupt is used for software real time counter. The divider is automatically
changed according to the PLL so that the timer always counts 6 MHz cycles (except for
a short while when the PLL is changed).
Rev. 0.202011-10-04
Page 57(90)
Page 58
PKP
MASTER
SLAVE 1SLAVE 2SLAVE 3
SCLK
MOSI
MISO
xCS3
xCS2
xCS1
MOSIMOSIMOSI
SCLKSCLKSCLK
MISOMISOMISO
xCSxCSxCS
VS1000 PROGRAMMER’S GUIDEVSMPG
16SPI v1.3 2005-06-09
16.1General
Figure 10: SPI Bus
SPI is a serial bus interface that allows for simple serial communication between one
host and potentially several slaves. As depicted in Figure 10, four different signals are
required for implementing SPI:
• SCLK (Master Serial Clock): a static serial clock, offered by the master.
• MOSI (Master Out / Slave In): Master’s output data. This output is always driven
by the master.
• MISO (Master In / Slave Out): Slave’s output data. By default, all slaves on the
bus are in high impedance state. When the slave’s chip select is activated, it turns
MISO to an output, and when it starts receiving SCLKs, it behaves as defined in
the slave’s specification.
• xCS (Chip Select): Every slave requires its own chip select. Without the chip select
signal, a slave may not listen to what happens on the SPI bus.
Although widely used, SPI is not a real standard. Because of this, there are many
different implementations, more or less compatible with each other. Also, a very similar
de-facto standard, SSI, is in wide use with e.g. D/A converters. Again, there exists
another de-facto standard very close to this, Microwire. Thus, if one wants to make an
SPI/SSI/Microwire master device that works with all kinds of different slaves, it must be
well configurable.
The SPI block can implement both a master and slave SPI mode. Figure 11 shows
the two different physical connections for the modes. Chip Select extensions in master
mode allow for implementing several SSI variants. Also, Microwire master mode may be
implemented with this same arrangement.
Figure 11: SPI Pins
The SPI block is quite flexible, and allows for many different SPI configurations. Input
and output clock edges may be set independently, and the whole clock may be inverted.
In master mode, it is possible to delay reading a value for a given number of clock
cycles after a given clock edge, making it possible to make SPI implementations that are
not dependent of the output clock edge of a slave device, with the price of decreased
maximum SPI speed.
The most typical SPI configuration is such that 8-bit transfers are written MSB first to
the bus at falling clock edges, and read at a rising clock edges. When a transfer is not
active, the clock is low. This case is presented in Figure 12 (SPI_CF_CLKOPOL=1).
In master mode, the SPI clock SCLK is created in the SPI block. MOSI, SCLK and
FSYNC are in output mode, and MISO in input mode. No pins are in high impedance
state.
The highest speed that can be expected to work is fs=
1
× fm, where fsis the SPI
2
speed and fmis the SPI block’s input clock.
If more than one slave devices are to be used, each device requires a separate chip
select signal. Chips selects are intended to be implemented with general I/O pins.
FSYNC is mainly intended to be used for SSI device synchronization purposes. If it is
not needed for synchronization, it can also be used to implement one chip select. This
approach makes it possible to create a chip select that is automatically deasserted when
a transfer is finished.
16.2.2Slave Mode
Figure 13: Example SPI Timing, Slave Mode
In slave mode, the SPI clock SCLK is created externally. MOSI, SCLK and xCS are
inputs, and MISO is only an output when xCS is active.Otherwise MISO is high
impedance, as can be seen in Figure 13. The high impedance state is handled outside the SPI block (with gpio control).
In slave mode, the external clock, SCLK is used for latching input bits asynchronously
to the master clock MCLK.
The highest recommended input clock speed is slightly lower than fs=
is the input SPI speed and fmis the SPI block’s input clock. The highest operable input
clock speed depends on the SPI block’s input clock speed, on the core clock speed, and
on the software.
There are three receive modes:
1. Interrupted xCS mode
Rev. 0.202011-10-04
1
×fm, where f
2
Page 60(90)
s
Page 61
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
2. Falling edge xCS mode
3. Rising edge xCS mode
In interrupted xCS mode the clock is only listened to if xCS is active. Reception starts
when xCS state changes from high to low. If xCS is deasserted in the middle of the
transfer, the reception is aborted.
In falling edge xCS mode reception starts when xCS state changes from high to low, but
transfer is not aborted if xCS changes from low to high mid-transfer. If another high to
low transition is encountered during the transfer of SPI_CF_DLEN+1 bits, the partially
received data is moved to the data register, SPI_ST_BREAK is set, interrupt 0 request
is sent, and a new transfer is initiated.
Rising edge xCS mode works like the falling edge xCS mode, except that the polarity of
the synchronization is reversed.
16.3Registers
SPI registers, prefix SPIx_
RegTypeResetAbbrevDescription
0r/w0CONFIG[10:0]Configuration
1r/w0CLKCONFIGClock configuration
2r/w0STATUS[7:0]Status
3r/w0DATASent / received data
4r/w0FSYNCSSI Sync data in master mode
5r/w0DEFAULTData to send (slave) if SPI_ST_TXFULL=’0’
16.3.1Main Configuration SPIx_CONFIG
SPIx_CONFIG Bits
NameBitsDescription
SPI_CF_SRESET11SPI software reset
SPI_CF_RXFIFOMODE10’0’ = interrupt always when a word is received,
’1’ = Interrupt only when FIFO register full or CS
deasserted with receive register full
SPI_CF_RXFIFO9Receive FIFO enable
SPI_CF_TXFIFO8Transmit FIFO enable
SPI_CF_XCSMODE7:6xCS mode in slave mode
SPI_CF_MASTER5Master mode
SPI_CF_DLEN4:1Data length in bits
SPI_CF_FSIDLE0Frame sync idle state
SPI_CF_XCSMODE selects xCS mode for slave operation. ’00’ is interrupted xCS
mode, ’10’ is falling edge xCS mode, and ’11’ is rising edge xCS mode.
Rev. 0.202011-10-04
Page 61(90)
Page 62
PKP
SCLK
SPI
block
SPI_CC_CLKPOL
SPI
block
SPI_CC_CLKPOL
MASTER MODESLAVE MODE
MUX
MUX
SCLK_int
SCLK_int
SCLK
VS1000 PROGRAMMER’S GUIDEVSMPG
SPI_CF_MASTER sets master mode. If not set, slave mode is used.
SPI_CF_DLEN+1 is the length of SPI data in bits. Example: For 8-bit data transfers, set
SPI_CF_DLEN to 7.
SPI_CF_FSIDLE contains the state of FSYNC when SPI_ST_TXRUNNING is clear.
This bit is only valid in master mode.
In master mode, SPI_CC_CLKDIV is the clock divider for the SPI block. The gener-
f
ated SCLK frequency f =
m
2×(c+1)
, where fmis the master clock frequency and c is
SPI_CC_CLKDIV. Example: With a 12 MHz master clock, SPI_CC_CLKDIV=3 divides
the master clock by 4, and the output/sampling clock would thus be f =
12MHz
2×(3+1)
=
1.5MHz.
SPI_CC_CLKPOL reverses the clock polarity. In master mode, the inverter is implemented as the last thing in the output clock data chain. In slave mode, it is implemented as the first thing in the input clock data chain.See Figure 14 for details.
If SPI_CC_CLKPOL is clear the data is read at rise edge and written at fall edge if
SPI_CC_CLKPHASE is clear. When SPI_CC_CLKPHASE is set the data is written at
rise edge and read at fall edge.
Figure 14: Normal and Reverese SPI Clock Polarity
SPI_CC_CLKPHASE defines the data clock phase. If clear the first data is written when
xcs is asserted and data is sampled at first clock edge (rise edge when SPI_CC_CLKPOL
= 0 and fall edge if SPI_CC_CLKPOL = 1). If SPI_CC_CLKPHASE is set the first data
is written a the first data clock edge and sampled at second.
Rev. 0.202011-10-04
Page 62(90)
Page 63
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
16.3.3Status SPIx_STATUS
SPIx_STATUS Bits
NameBitsDescription
SPI_ST_RXFIFOFULL7Receiver FIFO register full
SPI_ST_TXFIFOFULL6Transmitter FIFO register full
SPI_ST_BREAK5Chip select deasserted mid-transfer
SPI_ST_RXORUN4Receiver overrun
SPI_ST_RXFULL3Receiver data register full
SPI_ST_TXFULL2Transmitter data register full
SPI_ST_TXRUNNING1Transmitter running
SPI_ST_TXURUN0Transmitter underrun
SPI_ST_BREAK is set in slave mode if chip select was deasserted in interrupted xCS
mode or a starting edge is encountered in xCS edge modes while a data transfer was in
progress. This bit has to be cleared manually.
SPI_ST_RXORUN is set if a received byte overwrites unread data when it is transferred
from the receiver shift register to the data register. This bit has to be cleared manually.
SPI_ST_RXFULL is set if there is unread data in the data register.
SPI_ST_TXFULL is set if the transmit data register is full.
SPI_ST_TXRUNNING is set if the transmitter shift register is in operation.
SPI_ST_TXURUN is set if an external data transfer has been initiated in slave mode
and the transmit data register has not been loaded with new data to shift out. This bit
has to be cleared manually.
Note: Because TX and RX status bits are implemented as separate entities, it is relatively easy to make asynchronous software implementations, which do not have to wait
for an SPI cycle to finish.
16.3.4Data SPIx_DATA
SPIx_DATA[SPI_CF_DLEN:0] may be written to whenever SPI_ST_TXFULL is clear. In
master mode, writing will initiate an SPI transaction cycle of SPI_CF_DLEN+1 bits. In
slave mode, data is output as soon as suitable external clocks are offered. Writing to
SPIx_DATA sets SPI_ST_TXFULL, which will again be cleared when the data word was
put to the shift register. If SPI_ST_TXRUNNING was clear when SPIx_DATA was written
to, data can immediately be transferred to the shift register and SPI_ST_TXFULL won’t
be set at all.
When SPI_ST_RXFULL is set, SPIx_DATA may be read. Bits SPI_CF_DLEN:0 contain
the received data. The rest of the 16 register bits are set to 0.
Rev. 0.202011-10-04
Page 63(90)
Page 64
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
16.3.5SSI Synchronization SPIx_FSYNC
SPIx_FSYNC is meant for generation of potentially complex synchronization signals,
including several SSI variants as well as a simple enough automatic chip select signal.
SPIx_FSYNC is only valid in master mode.
If a write to SPIx_DATA is preceded by a write to SPIx_FSYNC, the data written to
SPIx_FSYNC is sent to FSYNC with the same synchronization as the data written
to SPIx_DATA is written to MOSI. When SPI_ST_TXRUNNING is clear, the value of
SPI_CF_FSIDLE is set to FSYNC.
If SPIx_DATA is written to without priorly writing to SPIx_FSYNC, the last value written
to SPIx_FSYNC is sent.
SPIx_FSYNC is double-buffered like SPIx_DATA.
16.4Interrupts
The SPI block has one interrupt.
Interrupt 0 request is sent when SPI_ST_BREAK is asserted, or when SPI_ST_TXFULL
or SPI_ST_TXRUNNING is cleared. This allows for sending data in an interrupt-based
routine, and turning chip select off when the device becomes idle.
16.5Changes from 1.2
A default data register is added. If in slave mode there is no data to send when it is
needed (SPI_ST_TXFULL is ’0’), the default data is sent (and SPI_ST_TXURUN is set
like before).
In addition to receive and transmit data registers another set of FIFO registers are
added. In normal mode these are not used. If SPI_CF_TXFIFO is set, two words can be
waiting while a third one is in transmit. An interrupt is generated when SPI_ST_TXFULL
becomes ’0’ (like before).
If SPI_CF_RXFIFO is set, RX FIFO register holds another received word while a third
one is in receive. When SPI_DATA is read and SPI_ST_RXFIFO is ’1’, the FIFO register
value is returned, otherwise the receive register value is returned.
Status register should be writable by user, i.e. it must be possible to clear the state of
FIFO and transmit/receive register indicators.
The clock configuratio register operations has changed. This device uses the common
SPI clocking configuration modes where data clock’s polarity and phase can be inverted.
Rev. 0.202011-10-04
Page 64(90)
Page 65
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
16.6VS1000 ROM code usage
The ROM code in VS1000 has the following usage for SPI:
At boot-up the SPI chip select is checked: if it’s pulled high, SPI boot is attempted.
When SPI is not active, the default player application uses the SPI data lines (SI and
SO) in GPIO mode as LED controls.
16.7Effect of Clock Multiplier
Note that the clock multiplier affects SPI speed. In VS1000 ROM you can read the
current clock multiplier setting in global variable
the SPI clock speed taking the clock multiplier into account:
The byte-wide bus peripheral implements a nand flash controller with vsdsp peripheral
bus interface. The peripheral can be configured for different speed/size memory devices.
The device has internal ECC calculation which provides the error detection data for the
dsp.
VS1000 Nand Flash interface uses chip’s master clock to generated IO signal transactions. Therefore changing master clock frequency changes also the interfaces’s AC
waveforms.
The Nand Flash controller requires that dsp controls the command latch enable (CLE)
and address latch enable (ALE) pins directly (as GPIO). Memory chip enable (NFCE)
can be controlled either as GPIO or automatically by the Nand Flash controller. Other
signals are generated with NF peripheral.
• NFCE : Chip enable, active low
• NFWR : write enable, active low
• NFRD : Read enable, active low
• NFDIO : 8-bit data bus, sampled at rising edge of NFRD and written at falling edge
of NFWR
• NFRDY : Ready/xBusy signal from flash chip. This signal must be at logic HIGH
state before read or write operation is started (command, address or data transaction). NFRDY requires external 10 kOhm pull-up resistor.
The nand flash IO signals can be read at any time through GPIO0_IDATA.
The peripheral provides clocked byte transfers of 1..32 bytes from an integrated buffer
memory freeing the DSP from having to generate clocking for each transferred byte. The
peripheral also provides standard Error Correcting Code (ECC) calculation for 1..512
byte blocks.
Configurable features include:
• Programmable address cycles from 1 to 32
• Programmable wait states from 0 to 63 (i.e. Read/write pulse time)
The nand flash controller consists of the memory interface signal generation unit and
ECC calculation and logging unit. These units can operate separately from each other.
The peripheral implements a memory mapped interface that generates the control signals for flash memory read/write operation. It also calculates and logs the parity bit
information from one read/write block. The block size is not limited but the byte counter
is only 9 bits. Reads/writes can be done one at a time or from a 32-byte data buffer in
bursts from 1 to 32 bytes at a time. Block diagram with the main registers is shown in
the next figure.
The architecture has timing control logic which controls the flash operation delay of each
write/read. This logic controls the NFWR, NFRD and NFCE signal toggling. NFWR and
NFRD pulses are always symmetric. Without wait states each write/read cycle takes two
master clock cycles. When waitstates are set to 1 each cycle takes 2+2 master clock
cycles. I.e. Each operation takes (waitstates+1) * 2 master clock cycles. Waitstates can
be set from 0 to 63 (6-bit register). For LCDs the chip select in write mode can be set to
toggle between bytes.
The 32-byte buffer memory consists of 16 addresses, 16 bits each. In the byte-wide bus
operations, the high 8 bits (MSB) are transferred first.
Rev. 0.202011-10-04
Page 67(90)
Page 68
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
17.3Registers
Nand flash controller user registers can be divided to three groups: the nand flash interface control registers, the dsp interface control registers and the ECC control/logging
registers. Register map is shown in the next table.
Byte-wide bus peripheral registers
OffsetTypeRegisterFunction
0rwCTRL[8:0]Byte-wide Bus (Nand Flash) Controller Control
1rLPL[15:0]Calculated Line Parity for 512-byte block
2rCP_LPH[7:0]Calculated Column Parity for 512-byte block
3rwDATA[15:0]Buffer Data read/write register
4rwNFIF[12:0]Buffer-to-Physical Interface Control
5rwDSPIF[7:0]Buffer-to-DSP Interface Control
6rECC_CNT[7:0]Error Correction Code counter
17.3.1Control register
NFLSH_CTRL bits
NameBitsDescription
lcd-ce-mode8Chip select operation mode in read/write cycles
int-enable7Interrupt enable
nf-sreset6Resets the controller
waitstates5:0Number of wait states in read/write cycles
Waitstates delays the read/write operation by (1+n)+(1+n) master clock cycles where n
is the number of wait states. I.e. The flash read/write enable low and high times are
both delayed.
17.3.2Line and Column parity registers
NFLSH_LPL bits
NameBitsDescription
lpl15:0Low part (bits 15:0) of Line Parity
NFLSH_CP_LPH bits
NameBitsDescription
cp7:2Calculated Column Parity bits (6 bits)
lph1:0High part (bits 17:16) of Line Parity
Lp and cp calculate the parity bits as descibed in Samsung’s Application Note for NAND
Flash Memory (Revision 2.0). The parity calculation can be used with or without actually
accessing any physical Nand Flash device. A nand operation can be active during ECC
calculation but it must be from/to the data buffer.
When ECC is enabled (ecc-ena=1), each read and write to the dreg register updates
Rev. 0.202011-10-04
Page 68(90)
Page 69
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
the ECC. ECC is calculated from the 16-bit values of dreg register.
The ECC generation uses the Hamming ECC principle. In case of 528 byte page nand
flash (small page) a 24 bit ECC is generated. This gives a performance of 2 bit detection and 1 bit correction. For 2112 byte page nand flash memories (large page) the
calculation can be done in 512 byte sections.
17.3.3Data register
NFLSH_DATA bits
NameBitsDescription
dreg15:0Data read/write register. Can be used with or
without ECC.
All data transfers to/from the are done through this register. The operation of NFLSH_DATA
depends from dsp-ena-dbuf, dsp-rd-wrx and nf-rd-wrx. When dsp-rd-wrx is set the register samples the data buffer (from pointer address dsp-dbuf-pntr) or the nand flash input
register (when dsp-ena-dbuf is low).
Data buffer reads/writes can be done in 16 consecutive clock cycles. It must be noted
that when the read mode (dsp-rd-wrd set) is selected it takes one clock cycle for the
control to transfer the first word from data buffer to dreg. Therefore it is recommended
that the read mode is set (+ ecc reset/enable/disable) as the nand flash operation is
started.
+ 1 bytes
nf-use-dbuf7write from buffer(1) or dreg register(0)
nf-dbuf-pntr6:2pointer address of the data buffer for next
read/write
nf-do-op1nand flash interface start operation bit (resets
when done)
nf-rd-wrx0read(1)/write(0) selection
NFIF control register can only be written in idle state. Current nand flash operation can
be terminated by setting the nf-sreset bit of the control register. When all bytes are
read/written an interrupt is given (if enabled)
Rev. 0.202011-10-04
Page 69(90)
Page 70
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
17.3.5Interface control towards DSP
NFLSH_DSPIF bits
NameBitsDescription
dsp-dbuf-pntr7:4Data buffer pointer for next operation
dsp-ena-dbuf3Use data buffer for operations (’1’ = enabled)
dsp-rd-wrx2Dsp read/write selection (’1’ = read)
ecc-ena1Ecc calculation enable
ecc-sreset0Ecc register reset bit (zeroed after one cycle)
When dsp-ena-dbuf is 0, the 32-byte buffer memory is not changed.
17.3.6ECC counter register
NFLSH_ECC_CNT bits
NameBitsDescription
ecc-cnt7:0Calculated ecc words (data is processed in 16-
bit format)
Ecc-cnt register counts the 16-bit words that are read or written to dreg. This information
is required when lpl, lph and cp are calculated. The register is updated only when the
ecc is enabled (ecc-ena = ’1’). In write operation the register is updated one clock cycle
after the write took place (as the data is being moved to the data buffer) and in the read
operation it is updated in the same clock cycle.
Rev. 0.202011-10-04
Page 70(90)
Page 71
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
17.4Timing
Figure 16. shows the signal generation for the command write operation when wait
states is 1. The write pulse duration can be calculated from equation:
T wl = 1/f
∗ (W S + 1), where
CLK I
CLKI is the internal clock frequency and WS is the nand flash IF wait state register.
Same principle applies to NFDIO signals.
Nand Flash Command Write Transaction
SymParameterCLKI cycMin@48MHzMax@48MHz
T
Command latch enable setup
cles
> 141.6ns
time
T
Command latch enable setup
cleh
> 141.6ns
time
T
ALE inactive to CLE active
cled
> 141.6ns
delay
T
NFCE active to NFWR active
ces
120.8ns20.8ns
delay
T
NFWR inactive to NFCE inac-
ceh
120.8ns20.8ns
tive delay
T
Write enable low time1+WS41.6ns
wl
T
T
T
Write enable high time1+WS41.6ns
wh
NFDIO data out setup time1+WS41.6ns
dos
NFDIO data out hold time1+WS41.6ns
doh
Figure 16: Nand Flash IF Command Write, WaitStates = 1
Rev. 0.202011-10-04
Page 71(90)
Page 72
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
Figure 17. shows the signal generation for the 4-byte address write operation when wait
states is 0.
The write pulse duration can be calculated from equation:
T wl = 1/f
∗ (W S + 1), where
CLK I
CLKI is the internal clock frequency and WS is the nand flash IF wait state register.
Same principle applies to NFDIO signals.
Figure 18. shows the signal generation for the 4-byte data read transaction when wait
states is 0.
The read pulse duration can be calculated from equation:
T rl = 1/f
∗ (W S + 1), where
CLK I
CLKI is the internal clock frequency and WS is the nand flash IF wait state register.
Nand Flash Data Read Transaction
SymParameterCLKI cycMin@48MHzMax@48MHz
T
CLE inactive to NFCE active
clei
> 141.6ns
delay
T
ALE inactive to NFCE active
alei
> 141.6ns
delay
T
NFCE active to NFRD active
ces
120.8ns20.8ns
delay
T
NFRD inactive to NFCE inac-
ceh
120.8ns20.8ns
tive delay
T
NFWR inactive to NFCE ac-
wed
> 141.6ns
tive delay
TrlRead enable low time1+WS20.8ns
T
Read enable high time1+WS20.8ns
rh
T
T
T
NFDIO data in setup time15ns
dis
NFDIO data in hold time0ns
dih
Data bus tri-state setup/hold
z2cs
120.8ns20.8ns
time from NFCE edge
Figure 18: Nand Flash IF 4-byte Data Read, WaitStates=0
Rev. 0.202011-10-04
Page 73(90)
Page 74
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
Figure 19. shows the signal generation for the 4-byte data write transaction when wait
states is 0.
The write pulse duration can be calculated from equation:
T wl = 1/f
∗ (W S + 1), where
CLK I
CLKI is the internal clock frequency and WS is the nand flash IF wait state register.
Nand Flash Data Write Transaction
SymParameterCLKI cycMin@48MHzMax@48MHz
T
CLE inactive to NFCE active
clei
> 141.6ns
deley
T
ALE inactive to NFCE active
alei
> 141.6ns
deley
T
NFCE active to NFWR active
ces
120.8ns20.8ns
delay
T
NFWR inactive to NFCE inac-
ceh
120.8ns20.8ns
tive delay
T
NFRD inactive to NFCE ac-
red
> 141.6ns
tive delay
T
Write enable low time1+WS20.8ns
wl
T
T
T
Write enable high time1+WS20.8ns
wh
NFDIO data out setup time1+WS20.8ns
dos
NFDIO data out hold time1+WS20.8ns
doh
Figure 19: Nand Flash IF 4-byte Data Write, WaitStates=0
Rev. 0.202011-10-04
Page 74(90)
Page 75
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
17.5VS1000 ROM code usage
The ROM code in VS1000 has the following usage for the Nand Flash controller:
At boot-up the Nand Flash chip select is checked: if it is pulled high, Nand flash scan
is attempted. NFCE is configured as a GPIO pin and asserted/deasserted in software.
Nand flash boot scan is performed using 660 ns read/write low time for access (27 waitstates, CLKI = 3.5x).
A number of access methods are used to attempt to read the first 512 bytes of the Nand
Flash chip and look for an 8-byte NandType record from the beginning of the block.
A string "VLSI" must be found from the beginning of the block to recognize a proper
NandType record.
The NandType record sets the proper access method for the Flash in question (small or
large page, number of address bytes) and specifies the device size and erasable block
size of the Flash chip (see datasheet).
A valid nand flash identification record also contains a setting for access time in nanoseconds. New waitstate setting is calculated from this value and the active internal clock for
each subsequent access.
The remaining 504 bytes of the first block and a specified number of additional sectors
(upto total of 16 sectors, i.e. 8192 bytes) can contain VS1000 boot code, which can
be used to load data to X data RAM, Y data RAM, or instruction RAM and optionally
execute code to extend or replace firmware functionality on chip.
If the FLASH type is not supported by the ROM firmware, but reading of at least the first
block is successful with one of the ROM read methods, the boot record can replace the
read method to continue boot.
17.5.1Nand Flash access methodology
VS1000 writes to the nand flash in blocks of 512 (data) + 16 (spare) bytes. single-level
cell (SLC) large page flashes (block size 2112) are mostly ok with this, but multi-level cell
(MLC) have problems with this so those are not supported by the ROM code. VS1000
ROM contains own wear levelling algorithm and logical-to-physical block mapper that
greatly extends the life of the nand flash chips.
MLC memories and larger than 2 kB page sizes can be supported with custom boot
code, as long as at least the first 512-byte sector can be successfully read using the
ROM boot method. The application in question determines how feasible this is.
Rev. 0.202011-10-04
Page 75(90)
Page 76
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
18Timers v1.0 2002-04-23
18.1General
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.
A timer has a 32-bit timer register for down counting and a 32-bit TIMER1_LH register
for holding the timer start value written by the processor. Timers have also a 2-bit
TIMER_ENA register. Each timer is enabled (1) or disabled (0) by a corresponding
bit of the enable register.
TIMER_CF_CLKDIV is the master clock divider for all timer clocks. The generated
f
internal clock frequency fi=
m
, where fmis the master clock frequency and c is
c+1
TIMER_CF_CLKDIV. Example: With a 12 MHz master clock, TIMER_CF_DIV=3 divides the master clock by 4, and the output/sampling clock would thus be fi=
3MHz.
The 32-bit start value TIMER_Tx[L/H] sets the initial counter value when the timer is
f
reset. The timer interrupt frequency ft=
i
where fiis the master clock obtained with
c+1
the clock divider (see Chapter 18.2.1 and c is TIMER_Tx[L/H].
Example: With a 12 MHz master clock and with TIMER_CF_CLKDIV=3, the master
clock fi= 3M H z. If TIMER_TH=0, TIMER_TL=99, then the timer interrupt frequency
3MHz
ft=
99+1
= 30kHz.
18.2.4Timer X Counter TIMER_TxCNT[L/H]
TIMER_TxCNT[L/H] contains the current counter values. By reading this register pair,
the user may get knowledge of how long it will take before the next timer interrupt.
Also, by writing to this register, a one-shot different length timer interrupt delay may be
realized.
18.3Interrupts
Each timer has its own interrupt, which is asserted when the timer counter underflows.
18.4VS1000 ROM code usage
The ROM code in VS1000 has the following usage for timers:
Timer 0 is used as the System Timer, updating a software real time counter that is used
for all timing of the ROM routines. Timer 1 is free for user applications.
The ROM software keeps the master clock divider at a value that results in a 6 MHz
counting frequency (12 MHz crystal). The frequency is stable except in 2 cases: 1)
When VS1000 changes its internal clock speed (PLL multiplier), the frequency can be
more or less than 6 MHz for a short time. 2) During USB suspend or low power pause
the frequency is less than 6MHz.
During USB activity the internal clock speed must be stable at 48 MHz so the timer
frequency is also stable at 6 MHz.
Rev. 0.202011-10-04
Page 77(90)
Page 78
PKP
Start
bit
D0
D1D2D3
D4
D5
D6D7
Stop
bit
VS1000 PROGRAMMER’S GUIDEVSMPG
19UART v1.11 2007-03-16
19.1General
RS232 UART implements a serial interface using rs232 standard.
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.
19.2Registers
UART registers, prefix UARTx_
RegTypeResetAbbrevDescription
0xC028r0STATUS[3:0]Status
0xC029r/w0DATA[7:0]Data
0xC02Ar/w0DATAH[15:8]Data High
0xC02Br/w0DIVDivider
19.2.1Status UARTx_STATUS
A read from the status register returns the transmitter and receiver states.
UARTx_STATUS Bits
NameBitsDescription
UART_ST_FRAMERR4Framing Error (stop bit was 0)
UART_ST_RXORUN3Receiver overrun
UART_ST_RXFULL2Receiver data register full
UART_ST_TXFULL1Transmitter data register full
UART_ST_TXRUNNING0Transmitter running
UART_ST_FRAMERR is set at the time of stop bit reception. When reception is functioning normally, stop bit is always “1”. If, however, “0” is detected at the line input at
the stop bit time, UART_ST_FRAMERR is set to “1”. This can be used to detect “break”
condition in some protocols.
UART_ST_RXORUN is set if a received byte overwrites unread data when it is transferred from the receiver shift register to the data register, otherwise it is cleared.
UART_ST_RXFULL is set if there is unread data in the data register.
Rev. 0.202011-10-04
Page 78(90)
Page 79
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
UART_ST_TXFULL is set if a write to the data register is not allowed (data register full).
UART_ST_TXRUNNING is set if the transmitter shift register is in operation.
19.2.2Data UARTx_DATA
A read from UARTx_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 UARTx_DATA sets a byte for transmission. The data is taken from bits 7:0,
other bits in the written value are ignored. If the transmitter is idle, the byte is immediately
moved to the transmitter shift register, a transmit interrupt request is generated, and
transmission is started. If the transmitter is busy, the UART_ST_TXFULL will be set and
the byte remains in the transmitter data register until the previous byte has been sent
and transmission can proceed.
19.2.3Data High UARTx_DATAH
The same as UARTx_DATA, except that bits 15:8 are used.
The divider is set to 0x0000 in reset. The ROM boot code must initialize it correctly
depending on the master clock frequency to get the correct bit speed. The second
divider (D2) must be from 6 to 255.
f
The communication speed f =
m
(D1+1)×(D2)
, where fmis the master clock frequency,
and f is the TX/RX speed in bps.
19.3Interrupts 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. Status bit [1] informs
Rev. 0.202011-10-04
Page 79(90)
Page 80
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
the transmitter data register empty (or full state) and bit [0] informs the transmitter (shift
register) empty state. A new word must not be written to transmitter data register if it
is not empty (bit [1] = ’0’). The transmitter data register will be empty as soon as it is
shifted to transmitter and the transmission is begun. It is safe to write a new word to
transmitter data register every time a transmit interrupt is generated.
Receiver operates as follows: It samples the RX signal line and if it detects a high to
low transition, a start bit is found. After this it samples each 8 bit at the middle of the
bit time (using a constant timer), and fills the receiver (shift register) LSB first. Finally if
a stop bit (logic high) is detected the data in the receiver is moved to the reveive data
register and the RX_INTR interrupt is sent and a status bit[2] (receive data register full)
is set, and status bit[2] old state is copied to bit[3] (receive data overrun). After that the
receiver returns to idle state to wait for a new start bit. Status bit[2] is zeroed when the
receiver data register is read.
RS232 communication speed is set using two clock dividers. The base clock is the
processor master clock. Bits 15-8 in these registers are for first divider and bits 7-0 for
second divider. RX sample frequency is the clock frequency that is input for the second
divider.
19.4VS1000 ROM code usage
The ROM code in VS1000 has the following usage for the UART:
UART receive is by default tied to the ROM monitor. If byte 0xef is received, the firmware
jumps to the monitor. This enables debugging via a serial cable using vsemu command
line tool and IDE environment available from VLSI.
The default communication speed of the UART is 115200 bit/s with a 12 MHz crystal.
VS1000 ROM automatically changes the UART divider according to the
variable whenever the PLL setting is changed.
uartByteSpeed
Rev. 0.202011-10-04
Page 80(90)
Page 81
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
20Universal Serial Bus Controller v1.0 2006-01-05
20.1General
The Universal Serial Bus Controller handles USB 1.1 data traffic at a 12 Mbit/s signalling
speed.
The USB device can handle traffic for the control endpoint (0) plus three input and output
endpoints. Bulk, Isochronous and Interrupt transfer modes are supported at Full Speed
(12 Mbit/s). The maximum packet size is 1023 bytes.
4 kilobytes of X data memory are used as the USB packet buffer: 2 KiB for incoming
packets (X:0x2C00-0x2FFF) and 2 KiB for outgoing packets (X:0x3000-0x33FF). The
input buffer is a ring buffer with incoming packets consisting of a status word and n data
words. The output buffer has 16 possible start locations for outgoing packets at 128byte (64-address) intervals (note that all data addressing in VS1000 is based on 16-bit
words).
20.2Registers
Universal Serial Bus Controller Registers
AddressRegisterFunction
0xC080USB_CONFIGUSB Device Config
0xC081USB_CONTROLUSB Device Control
0xC081USB_STATUSUSB Device Status
0xC082USB_RDPTRReceive buffer read pointer
0xC083USB_WRPTRReceive buffer write pointer
0xC088USB_EP_SEND0EP0IN Transmittable Packet Info
0xC089USB_EP_SEND1EP1IN Transmittable Packet Info
0xC08AUSB_EP_SEND2EP2IN Transmittable Packet Info
0xC08BUSB_EP_SEND3EP3IN Transmittable Packet Info
0xC090USB_EP_ST0Flags for endpoints EP0IN and EP0OUT
0xC091USB_EP_ST1Flags for endpoints EP1IN and EP1OUT
0xC092USB_EP_ST2Flags for endpoints EP2IN and EP2OUT
0xC093USB_EP_ST3Flags for endpoints EP3IN and EP3OUT
Rev. 0.202011-10-04
Page 81(90)
Page 82
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
20.2.1USB_CONFIG - USB Device Config 0xC080
USB_CONFIG bits
NameBitsDescription
reset15Reset Active
dtogg-host14Reset value of host data toggle (set to 0)
dtogg-device13Reset value of device data toggle (set to 0)
debug12-1112:11Debug bits (set to 0)
dtogg-errctl10Data Toggle error control (set to 0)
reserved99Reserved (set to 0)
rstusb8Reset receiver (set to 0)
usb-enable7Enable USB
usb-address6:0Current USB address
20.2.2USB_CONTROL - USB Device Control 0xC081
USB_CONTROL bits
NameBitsDescription
USB_STF_BUS_RESET15Interrupt mask for bus reset
USB_STF_SOF14Interrupt mask for start-of-frame
USB_STF_RX13Interrupt mask for receive data
USB_STF_TX_READY12Interrupt mask for transmitter holding register
empty
USB_STF_TX_EMPTY11Interrupt mask for transmitter empty (idle)
USB_STF_NAK10Interrupt mask for NAK packet sent to host
Software should write “1” to usb-configured bit when completing the USB Chapter 9
Set_Configuration request. Setting this bit loads all device and host side data toggle registers with the defaults set at the dtogg-host and dtogg-device bits at the USB_CONFIG
register. The dtogg-host and dtogg-device bits should normally always be “0”.
VS1000A ROM does not use the USB interrupt.
VS1000B ROM uses the USB interrupt for SOF detection to detect USB suspend condition.
Rev. 0.202011-10-04
Page 82(90)
Page 83
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
20.2.3USB_STATUS - USB Device Status 0xC082
USB_STATUS bits
NameBitsDescription
USB_STF_BUS_RESET15Bus reset occurred
USB_STF_SOF14Start-of-frame
USB_STF_RX13Receive data
USB_STF_TX_READY12Transmitter holding register empty
USB_STF_TX_EMPTY11Transmitter empty (idle)
USB_STF_NAK10NAK packet sent to host
USB_STF_SETUP7Setup packet received
USB_STM_LAST_EP3:0Endpoint number of last rx/tx transaction
The USB_STM_LAST_EP can be used mainly for debugging purposes, final software
should be able to work without it.
This buffer marks the index position of the last word that the DSP has successfully read
from the receive packet buffer. DSP should control this register and update the position
after each packet it has read from the receive buffer. After reset this register is zero.
After a packet has been received from the PC, the USB hardware updates this pointer to
the receive buffer memory. USB_WRPTR is index location of the next free word location
in the USB receive buffer. When USB_RDPTR equals to USB_WRPTR, the packet input
buffer is empty. After reset this register is zero.
Rev. 0.202011-10-04
Page 83(90)
Page 84
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
20.2.6USB_EP_SENDn - EPnIN Transmittable Packet Info 0xC088..0xC08B
USB_EP_SENDn bits
NameBitsDescription
txpkt-ready15Packet ready for transmission
start-addr13:10Starting location of packet
length9:0Length of packet in bytes (0..1023)
When the DSP has written a packet into the transmit buffer, that is ready to be transmitted to the PC by an endpoint, the DSP signals the USB firmware by setting the
value of the USB_EP_SENDn register of the endpoint that should transmit the packet
(USB_EP_SEND0 for endpoint 0, USB_EP_SEND1 for endpoint 1 etc).
The txpkt-ready bit should be set to “1” by the DSP. When the packet information (not
contents) is loaded to the internal Transmit Holding Register of the endpoint, txpkt-ready
bit is set to “0” by the hardware. Note that this does not indicate that the packet is sent
to the PC, merely that it is ready for sending when the PC next requests “IN” data for
that endpoint. Scanning the txpkt-ready bit merely allows software to prepare the next
packet to be sent even before the previous packet has been sent to the PC.
The start-addr field is index to a 64-word boundary in the transmit buffer memory area.
The actual memory location that start-addr corresponds to is calculated by:
packetstartaddress=USB_SEND_MEM+(start-addr×64)
which in VS1000 corresponds to address X:0x3000 for start-addr=0, X:0x3040 for startaddr=1 etc.
20.2.7USB_EP_STn - Endpoint flags EPnIN and EP0nUT 0xC090..0xC093
USB_EP_STn bits
NameBitsDescription
EPnOUT (PC → Device) endpoint (0 .. 3) flags
out-type15:1400=bulk 01=interrupt 11=isochronous
out-enable14:131=enabled 0=disabled
out-forcestall12Force STALL
out-stall-sent11At least 1 STALL sent
reserved10:8Set to 0
EPnIN (Device → PC) endpoint (0 .. 3) flags
in-type7:600=bulk 01=interrupt 11=isochronous
in-enable51=enabled 0=disabled
in-forcestall4Force STALL
in-stall-sent3At least 1 STALL sent to PC
in-nak-sent2At least 1 NAK sent to PC
in-xmit-empty1Transmitter empty
reserved0Set to 0
Rev. 0.202011-10-04
Page 84(90)
Page 85
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
20.3Receiving Packets from PC (EP0OUT, EP1OUT, ... , EP3OUT)
The USB hardware handles all necessary token (ACK, NAK, IN, OUT, SETUP, STALL)
sending and receiving. The software sees only the data packet contents plus some state
information about the sent tokens.
20.3.1Reception
All received packets for all endpoints arrive to the same 2 KiB (1 KiW) ring buffer memory in X address space. This maximizes memory usage efficiency, but leads to one
important side-effect: The USB specification dictates that an incoming SETUP transfer
to the control endpoint must be the first packet to be processed at all times.
For instance the PC might issue a SETUP control request to the control endpoint before
the software has had time to process a data packet that has previously arrived to a data
endpoint. In such a case, the software should ignore the pending data and handle the
SETUP packet instead.
For achieving this functionality, the hardware can test the USB_STF_SETUP bit at the
USB_CONTROL register. If it is “1”, all packets until the last received SETUP packet
need to be truncated and the last SETUP packet processed. A reasonably fast USB
implementation should be able to achieve this without problems, but delays of several
milliseconds (such as for sending debug messages etc) can cause problems with this
clause, which result in “random hang-ups” of the USB communication with the PC. If care
is taken to process the packets in the correct order, most (if not all) USB transactions
can perfectly well cope with delays of several seconds. In practice the PC waits patiently
for several seconds if the data you send is “correct,” e.g. what the PC expects, but very
quickly responds to any unexpected data by issuing a bus reset.
Software can detect a received packet by scanning the USB_RDPTR and USB_WRPTR
registers. When their values differ, there is a packet ready for processing in the input
buffer.
USB_RDPTR points now to a header word. The actual packet data words are in the
buffer memory after the header word. The packet header word has the following structure:
Packet header word bits
NameBitsDescription
crc-err151=CRC error detected
setup141=SETUP packet, 0=DATA packet
endpoint13:10Endpoint to which the packet is addressed to
pktlength9:0Length of packet in bytes
This is immediately followed by (pktlength+1)/2 data words, MSB first.
A quick routine can access the contents directly in the buffer memory, or choose to copy
the packet contents to another location in memory. In either case, the software should
Rev. 0.202011-10-04
Page 85(90)
Page 86
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
update the value of USB_RDPTR, indicating that the packet is no longer needed.
The USB hardware automatically NAK’s incoming data packets if there is less than
40 words space left in the buffer memory. In this situation the hardware still accepts
SETUP packets. If receiving a packet would cause the USB_WRPTR to be overrun by
USB_RDPTR, e.g. there is no more room for even the SETUP packet, even the SETUP
packets are NAK’ed.
20.3.2Sending Packet to PC (EP0IN, EP1IN, ... , EP3IN)
To send a USB packet, software must prepare the packet to the transmit buffer area,
starting at a 64-word boundary. The data is to be stored in Big Endian format, e.g.
the first byte to be sent should be in the most significant 8 bits of the first word. Next,
software should load the USB_EP_SEND register of the chosen endpoint with the start
location selector and size of the transmittable packet (in bytes). The most significant bit
of the register (txpkt-ready) should be set to “1”.
When the internal Transmit Holding Register for the endpoint is ready, the value of the
USB_EP_SEND register is loaded to the internal Transmit Holding Register and txpktready bit of the USB_EP_SEND register is set to “0”. This indicates that the packet is
queued for transmission and the USB_EP_SEND register can be loaded with information about the next sendable packet (if any).
To get information about when the packet has actually been transmitted to the PC, the
Transmitter Idle (in-xmit-empty) bit of the endpoint’s USB_EP_ST register can be polled
(or the corresponding interrupt used).
20.3.3How to know that the PC is expecting data
During software development, when protocol matters can be still somewhat unclear, it
is sometimes difficult to know when the PC actually is expecting you to send a packet
to some endpoint. In the USB hardware there is a feature to assist in finding out this
information: the endpoint’s in-nak-sent bit of the endpoint’s USB_EP_ST register. Using
this bit can avoid a common pitfall: loading a transmitter register with packet that is never
actually requested by a PC. That would cause the packet information to remain in the
transmitter register (until next USB reset), which again would cause the packet to be
sent as an answer to the next request of the PC, causing unexpected results.
20.3.4Stalling
STALL is a special condition on the USB bus, which more or less states, that “I can’t
handle this data packet now nor in the future”. For example when the software needs to
STALL reception of data from PC, software should set out-forcestall to “1” and out-stallsent to “0”. The hardware will then wait for the next OUT token from the PC and respond
Rev. 0.202011-10-04
Page 86(90)
Page 87
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
with STALL token. Bit out-stall-sent indicates that a STALL token has been successfully
transmitted to the PC.
A more common case of stalling regards the handling of control requests (SETUP messages sent to the control endpoint). In case of receiving an unsupported request, the
device should respond wit a stall. Since the control endpoint must remain open for the
next request for the PC and stalling a control request should be a rare event, a possible
way to handle this is:
• In the USB_EP_ST0 register, set out-forcestall to “1” and out-stall-sent to “0”
• Busy loop until out-stall-sent is “1” OR a USB reset occurs OR a time-out occurs
• Set out-forcestall to “0”
In a normal case this would send a single STALL to the control endpoint and leave the
endpoint open for the next request.
If an endpoint’s (other than 0) Halt feature is set (USB Chapter 9 standard request), the
endpoint should be stalled (forcestall set to “1”).
Mass storage class device can use STALL to end a bulk transfer [Axelson, J.: USB Mass
Storage].
20.4VS1000 ROM code usage
The ROM code in VS1000 has the following usage for the USB:
• Endpoint 0: USB Standard Requests (USB Chapter 9 functionality)
• Endpoint 1 OUT: USB Speakers
• Endpoint 2 OUT: Mass Storage Class (PC → VS1000)
• Endpoint 3 IN: Mass Storage Class (VS1000 → PC)
Depending on the state of GPIO0:6 during boot-up, the descriptors sent to the PC select
either Audio or Mass Storage functionality.
Rev. 0.202011-10-04
Page 87(90)
Page 88
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
20.4.1Augmenting the ROM functionality
Changing only the descriptors is easy since the descriptors are accessed via a descriptor pointer table in RAM that consists of 6 pointers to X memory:
Because the configuration descriptor is actually a set of descriptors, its size is stored
in USB.configurationDescriptorSize. For other descriptors, the size is taken from the
descriptor itself.
Note: A good storage driver should overwrite the serial number string descriptor with a
unique one. For a NAND flash, this could be done easily in the first sector’s optional boot
code. Since the USB.descriptorTable default values are loaded at each USB init (attacj),
the most straightforward way to do this would be to hook the DecodeSetupPacket()
function to load USB.descriptorTable[3] and call the RealDecodeSetupPacket() in ROM.
USB-related software hooks are:
• void USBHandler() - USB task handler
• void DecodeSetupPacket() - handles SETUP packets to EP0OUT
• void MSCPacketFromPC() - handles mass storage class command packets
• void ScsiTaskHandler() - handles (pending) disk operations
Hooking means replacing a ROM function with a RAM function by setting the hook vector
address. This is normally used to augment or replace functionality of the ROM code. In
most cases, the original ROM function can be called after handling some special case
in the RAM function. The ROM functions are called by using a function name with prefix
“Real”.
Rev. 0.202011-10-04
Page 88(90)
Page 89
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
20.4.2Hooking: Example
This example augments the USBHandler to blink LED 2 if there is an uncomplete disk
write operation.
or by setting the hook vector directly in the boot record (via a Set X Memory directive).
Note that since VS1000B the blinking LED is implemented in the ROM firmware.
20.4.3Used memory areas
The USB transmitting routines in VS1000 ROM are limited to transmitting packets of
max. 64 bytes. Only the first 512 bytes (addresses X:0x3000-0x30FF) of transmit packet
memory is used, leaving 1536 bytes (768 words) of X memory (addresses X:31000x33ff) free for other uses. However, in future revisions of the chip (VS1000E etc..) this
memory may not be available.
Rev. 0.202011-10-04
Page 89(90)
Page 90
PKP
VS1000 PROGRAMMER’S GUIDEVSMPG
21Watchdog v1.0 2002-08-26
21.1General
The watchdog consist of a watchdog counter and some logic. After reset, the watchdog
is inactive. The counter reload value can be set by writing to WDOG_CONFIG. The
watchdog is activated by writing 0x4ea9 to register WDOG_RESET. Every time this is
done, the watchdog counter is reset. Every 65536’th clock cycle the counter is decremented by one. If the counter underflows, it will activate vsdsp’s internal reset sequence.
Thus, after the first 0x4ea9 write to WDOG_RESET, subsequent writes to the same
register with the same value must be made no less than every 65536×WDOG_CONFIG
clock cycles.
Once started, the watchdog cannot be turned off. Also, a write to WDOG_CONFIG
doesn’t change the counter reload value.
After watchdog has been activated, any read/write operation from/to WDOG_CONFIG
or WDOG_DUMMY will invalidate the next write operation to WDOG_RESET. This will
prevent runaway loops from resetting the counter, even if they do happen to write the
correct number. Writing a wrong value to WDOG_RESET will also invalidate the next
write to WDOG_RESET.
Reads from watchdog registers return undefined values.