![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
user?s manual target devices pd77113a pd77114 pd77210 pd77213 sAP77016-B11 wma decoder middleware document no. u15683ej1v0um00 (1st edition) date published january 2002 n cp(n) printed in japan 1999 ? 2002
user?s manual u15683ej1v0um 2 [memo] user?s manual u15683ej1v0um 3 windows and windows media are either trademarks or registered trademarks of microsoft corporation in the united states and/or other countries. m8e 00. 4 the information in this document is current as of january, 2002. the information is subject to change without notice. for actual design-in, refer to the latest publications of nec's data sheets or data books, etc., for the most up-to-date specifications of nec semiconductor products. not all products and/or types are available in every country. please check with an nec sales representative for availability and additional information. no part of this document may be copied or reproduced in any form or by any means without prior written consent of nec. nec assumes no responsibility for any errors that may appear in this document. nec does not assume any liability for infringement of patents, copyrights or other intellectual pr operty rights of third parties by or arising from the use of nec semiconductor products listed in this document or any other liability arising from the use of such products. no license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual pr operty rights of nec or others. descriptions of circuits, software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples. the incorporation of these circuits, software and information in the design of customer's equipment shall be done under the full responsibility of customer. nec assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits, software and information. while nec endeavours to enhance the quality, reliability and safety of nec semiconductor products, customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. to minimize risks of damage to property or injury (including death) to persons arising from defects in nec semiconductor products, customers must incorporate sufficient safety measures in their design, such as redundancy, fire-containment, and anti-failure features. nec semiconductor products are classified into the following three quality grades: "standard", "special" and "specific". the "specific" quality grade applies only to semiconductor products developed based on a customer-designated "quality assurance program" for a specific application. the recommended applications of a semiconductor product depend on its quality grade, as indicated below. customers must check the quality grade of each semiconductor product bef ore using it in a particular application. "standard": computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots "special": tr ansportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support) "specific": aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems and medical equipment for life support, etc. the quality grade of nec semiconductor products is "standard" unless otherwise expressly specified in nec's data sheets or data books, etc. if customers wish to use nec semiconductor products in applications not intended by nec, they must contact an nec sales representative in advance to determine nec's willingness to support a given application. (note) (1) "nec" as used in this statement means nec corporation and also includes its majority-owned subsidiaries. (2) "nec semiconductor products" means any semiconductor product developed or manufactured by or for nec (as defined above). ? ? ? ? ? ? user?s manual u15683ej1v0um 4 regional information some information contained in this document may vary from country to country. before using any nec product in your application, piease contact the nec office in your country to obtain a list of authorized representatives and distributors. they will verify: ? device availability ? ordering information ? product release schedule ? availability of related technical literature ? development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, ac supply voltages, and so forth) ? network requirements in addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country. nec electronics inc. (u.s.) santa clara, california tel: 408-588-6000 800-366-9782 fax: 408-588-6130 800-729-9288 nec electronics hong kong ltd. hong kong tel: 2886-9318 fax: 2886-9022/9044 nec electronics hong kong ltd. seoul branch seoul, korea tel: 02-528-0303 fax: 02-528-4411 nec electronics singapore pte. ltd. novena square, singapore tel: 253-8311 fax: 250-3583 nec electronics taiwan ltd. taipei, taiwan tel: 02-2719-2377 fax: 02-2719-5951 nec do brasil s.a. electron devices division guarulhos-sp, brasil tel: 11-6462-6810 fax: 11-6462-6829 j01.12 nec electronics (europe) gmbh duesseldorf, germany tel: 0211-65 03 01 fax: 0211-65 03 327 ? branch the netherlands eindhoven, the netherlands tel: 040-244 58 45 fax: 040-244 45 80 ? branch sweden taeby, sweden tel: 08-63 80 820 fax: 08-63 80 388 nec electronics (uk) ltd. milton keynes, uk tel: 01908-691-133 fax: 01908-670-290 nec electronics italiana s.r.l. milano, italy tel: 02-66 75 41 fax: 02-66 75 42 99 nec electronics (france) s.a. v lizy-villacoublay, france tel: 01-3067-58-00 fax: 01-3067-58-99 nec electronics (france) s.a. representaci?n en espa?a madrid, spain tel: 091-504-27-87 fax: 091-504-28-60 user?s manual u15683ej1v0um 5 preface target readers this manual is for users who design and develop pd77016 family application systems. pd77016 family is the generic name for the pd7701x family ( pd77015, 77016, 77017, 77018a, 77019), the pd77111 family ( pd77110, 77111, 77112, 77113a, 77114, 77115), and the pd77210 family ( pd77210, 77213). however, this manual is for pd77113a, 77114, 77210, and 77213 devices. purpose the purpose of this manual is to help users understand the supporting middleware when designing and developing pd77016 family application systems. organization this manual consists of the following contents. chapter 1 introduction chapter 2 library specifications chapter 3 installation chapter 4 system example appendix a sample program source how to read this manual it is assumed that the reader of this manual has general knowledge in the fields of electrical engineering, logic circuits, microcontrollers, and the c language. to learn about pd77111 family hardware functions refer to pd77111 family architecture user?s manual . to learn about pd77016 family instruction functions refer to pd77016 family instruction user?s manual . conventions data significance: higher digits on the left and lower digits on the right active low representation: xxx (overscore over pin or signal name) note : footnote for item marked with note in the text caution : information requiring particular attention remark : supplementary information numerical representation: binary ... xxxx or 0bxxxx decimal ... xxxx hexadecimal ... 0xxxxx 6 user?s manual u15683ej1v0um related documents the related documents indicated in this publication may include preliminary versions. however, preliminary versions are not marked as such. documents related to devices user?s manual application note document name part number pamphlet data sheet architecture instructions basic software pd77113a pd77114 u14373e u14623e pd77210 pd77213 u12395e u15203e to be prepared u13116e u11958e documents related to development tools document name document no. function u14397e rx77016 user?s manual configuration tool u14404e rx77016 application note host api u14371e caution the related documents listed above are subject to change without notice. be sure to use the latest version of each document for designing. user?s manual u15683ej1v0um 7 contents chapter 1 introduction ...................................................................................................... ...........10 1.1 middleware.................................................................................................................. .................10 1.2 wma decoder................................................................................................................. .............10 1.3 product overview............................................................................................................ ............10 1.3.1 features .................................................................................................................. .........................10 1.3.2 operating environment ..................................................................................................... ................12 1.3.3 performance ............................................................................................................... ......................13 1.3.4 directory configuration................................................................................................... ...................14 chapter 2 library specifications........................................................................................... ..15 2.1 library overview ............................................................................................................ .............15 2.2 application processing flow................................................................................................. ....16 2.3 function specifications ..................................................................................................... ........17 2.3.1 wmad_filedecodeinit function............................................................................................. .............17 2.3.2 wmad_filedecodedata function .............................................................................................. .........18 2.3.3 wmad_filegetpcm function .................................................................................................. ...........19 2.3.4 wmad_getversion function.................................................................................................. .............20 2.3.5 wmad_filedecodeinfo function.............................................................................................. ...........21 2.3.6 wmad_filecbgetdata function (user-defined function)....................................................................22 2.4 error information........................................................................................................... ..............25 2.5 memory configuration........................................................................................................ ........26 2.5.1 scratch area .............................................................................................................. .......................27 2.5.2 static area ............................................................................................................... .........................28 2.5.3 i/o buffers ............................................................................................................... ..........................29 2.5.4 structures ................................................................................................................ .........................31 chapter 3 installation...................................................................................................... .............32 3.1 installation procedure ...................................................................................................... ..........32 3.2 sample creation procedure................................................................................................... ....32 3.3 change of location.......................................................................................................... ...........33 3.4 symbol naming conventions ................................................................................................... .33 chapter 4 system example................................................................................................... ........34 4.1 environment required for simulation using timing files .....................................................34 4.2 input data file creation.................................................................................................... ..........34 4.3 simulation.................................................................................................................. ..................35 4.4 sample program outline ...................................................................................................... ......36 4.4.1 sample program ............................................................................................................ ...................36 4.4.2 user-defined functions.................................................................................................... ..................36 4.5 sample program processing flow............................................................................................38 appendix a sample program source ......................................................................................41 a.1 sample source files ......................................................................................................... ..........41 a.1.1 sample.asm ................................................................................................................ ......................41 a.1.2 smp_data.asm .............................................................................................................. ....................54 8 user?s manual u15683ej1v0um a.1.3 smp_user.asm .............................................................................................................. ................... 55 a.2 sample header file .......................................................................................................... .......... 61 a.2.1 wma_dec.h................................................................................................................. ...................... 61 a.3 sample timing files......................................................................................................... .......... 63 a.3.1 smp_input.tmg ............................................................................................................. .................... 63 a.3.2 smp_serout.tmg ............................................................................................................ ................... 65 a.3.3 clk_for_2ch.tmg........................................................................................................... ..................... 68 user?s manual u15683ej1v0um 9 list of figures figure no. title page 1-1 sAP77016-B11 directory configuration ........................................................................................... ........... 14 2-1 application processing flow................................................................................................. ......................... 16 2-2 setting data in input buffer................................................................................................ ............................ 24 2-3 example of securing scratch area............................................................................................ .................... 27 2-4 example of securing static area ............................................................................................. ...................... 28 2-5 example of securing i/o buffers ............................................................................................. ...................... 29 4-1 input data file ............................................................................................................. .................................. 34 4-2 configuration of sample user-defined function buffer........................................................................ ......... 36 4-3 initialization and decode processing flow ................................................................................... ................. 38 4-4 predecode processing flow ................................................................................................... ....................... 39 4-5 main decode processing flow ................................................................................................. ..................... 40 list of tables table no. title page 1-1 bit rates and sampling frequencies supported by each codec.................................................................. 11 1-2 required memory size ........................................................................................................ .......................... 12 1-3 software tools.............................................................................................................. ................................. 12 1-4 mips values required for wma decode processing .............................................................................. ..... 13 2-1 library function list ....................................................................................................... ............................... 15 2-2 user-defined function list .................................................................................................. .......................... 15 2-3 error code list ............................................................................................................. ................................. 25 2-4 memory size required for each bit rate ...................................................................................... ................ 26 2-5 recommended output buffer size .............................................................................................. .................. 30 2-6 members of file information structure ....................................................................................... ................... 31 2-7 members of contents information structure ................................................................................... ............... 31 3-1 segment names............................................................................................................... ............................. 33 3-2 naming conventions .......................................................................................................... ........................... 33 user?s manual u15683ej1v0um 10 chapter 1 introduction 1.1 middleware middleware is the name given to a group of software that has been tuned so that it draws out the maximum performance of the processor and enables processing that is conventionally performed by hardware to be performed by software. the concept of middleware was introduced with the development of a new high-speed processor, the dsp, in order to facilitate operation of the environments integrated in the system. by providing appropriate speech codec and image data compression/decompression-type middleware, nec is offering users the kind of technol ogy essential in the realization of a multimedia system for the pd77016 family, and is continuing its promotion of system development. the sAP77016-B11 introduced here is middleware that supplies decoding functions using windows media? audio (wma) technology. 1.2 wma decoder windows media audio is the audio standard of the windows media technology (wmt) audio/video streaming technology promoted by microsoft corporation. wma is based on the microsoft-standard advanced systems format (asf) and is used together with the mpeg-4 (moving picture experts group) and wmv (windows media video) standards. the sAP77016-B11 performs decoding using wma decoding technology. 1.3 product overview 1.3.1 features ? all bit rates and sampling frequency data encoded by windows media audio codec versions 2, 7, and 8 can be decoded (refer to table 1-1 bit rates and sampling frequencies s upported by each codec ). ? decoding results are output in 16-bit linear pcm format ? the asf file format is supported ? extracting and decoding only audio data from data including video is possible ? contents information can be read out ? drm (digital rights management), script commands, and marker functions are not s upported chapter 1 introduction user?s manual u15683ej1v0um 11 table 1-1. bit rates and sampling frequencies s upported by each codec bit rate [bps] sampling frequency [hz] number of channels wma codec version 8 wma codec version 7 wma codec version 2 192,000 48,000 2 ?? 160,000 48,000 2 ?? 128,000 48,000 2 ?? 192,000 44,100 2 ?? 160,000 44,100 2 ?? 128,000 44,100 2 ?? 96,000 44,100 2 ?? 80,000 44,100 2 ?? 64,000 44,100 2 ?? 48,000 44,100 2 ? 32,000 44,100 2 ?? 48,000 44,100 1 ?? 32,000 44,100 1 ?? 64,000 32,000 2 ?? 48,000 32,000 2 ?? 44,000 32,000 2 ?? 40,000 32,000 2 ?? 36,000 32,000 2 ?? 32,000 32,000 2 ?? 22,000 32,000 2 ?? 32,000 32,000 1 ?? 20,000 32,000 1 ?? 32,000 22,050 2 ?? 22,000 22,050 2 ?? 20,000 22,050 2 ?? 20,000 22,050 1 ?? 16,000 22,050 1 ?? 20,000 16,000 2 ?? 16,000 16,000 2 ?? 16,000 16,000 1 ?? 12,000 16,000 1 ?? 10,000 16,000 1 ?? 10,000 11,025 1 ?? 8,000 11,025 1 ?? 12,000 8,000 2 ?? 8,000 8,000 1 ?? 6,000 8,000 1 ?? 5,000 8,000 1 ?? 128 note 8,000 1 ?? note although this value may be selected when video-only data is encoded, valid audio data is not included. remark : supported, ? : non-existent combination chapter 1 introduction user?s manual u15683ej1v0um 12 1.3.2 operating environment (1) operating target dsp: pd77113a, 77114, 77210, 77213 (2) required memory size: the sAP77016-B11 requires the memory sizes shown in the following table in order to support all the bit rates. table 1-2. required memory size memory type size [kwords] instruction memory ? 12.6 ram 10.5 x memory rom 17.5 ram 12.5 y memory rom 9.6 cautions 1. one word is 32 bits in the instruction memory and 16 bits in the x and y memories. 2. the memory size does not include pcm data and bit stream data buffers. note also that the required memory size can be reduced by limiting the supported bit rates. for details, refer to 2.5 memory configuration. (3) software tools (windows? version): table 1-3. software tools target dsp software tool pd77016 family dsp tools wb77016 (workbench) hsm77016 (high-speed simulator) lb77016 (librarian) chapter 1 introduction user?s manual u15683ej1v0um 13 1.3.3 performance the mips values required to perform wma decoding in real time are shown in table 1-4 mips values required for wma decode processing . [measurement conditions] ? simulator: hsm77016 ? evaluation results: measure the processing capacity when each wma file is decoded to determine the typical and maximum values. ? assign the values shown in table 2-5 recommended output buffer size for the decode processing unit (number of samples) and output buffer size. ? the mips values only indicate the processing capacity of the wmad_filedecodedata and wmad_filegetpcm functions used for decoding and wmad_filecbgetdata function; the processing capacity of other functions and the interrupt handler, etc., is not included. use the file attached as a sample for the user-defined wmad_filecbgetdata function. note that the processing capacity may differ depending on the system configuration. table 1-4. mips values required for wma decode processing decoding conditions processing capacity bit rate [kbps] sampling frequency [khz] number of channels typical mips value [mips] maximum mips value [mips] 22 22 2 28 51 22 32 2 44 74 32 32 2 27 47 192 48 2 41 71 caution the maximum mips value may be larger than the values shown in table 1-4 depending on the data. it is recommended to implement measures such as outputting a silent sound for a section that cannot perform decode processing in real time, on the system side. chapter 1 introduction user?s manual u15683ej1v0um 14 1.3.4 directory configuration the directory configuration in the sAP77016-B11 is shown below. figure 1-1. sAP77016-B11 directory configuration sample header file project file sample source file user-defined function sample source file data area sample source file data input timing file serial clock timing file serial output timing file library for instruction segments constant data library for rom segments constant data library for ram segments wma_dec.h: sample.prj: sample.asm: smp_user.asm: smp_data.asm: smp_input.tmg: clk_for_2ch.tmg: smp_serout.tmg: wmadec wmad.lib: wmad_rom.lib: wmad_ram.lib: smp library the directories are outlined below. (1) library stores the library files. ? wmad.lib: library file for instruction segments ? wmad_rom.lib: constant data library file for rom segments select when allocating constant data to rom. ? wmad_ram.lib: constant data library file for ram segments select when allocating constant data to ram. (2) smp/wmadec stores the source, header, and simulation timing files of the sample program. simulation can be performed using the high-speed simulator by utilizing these timing files (refer to 4.1 environment required for simulation using timing files ). user?s manual u15683ej1v0um 15 chapter 2 library specifications this chapter describes the function specifications and function call regulations in the sAP77016-B11. 2.1 library overview the sAP77016-B11 provides the following five functions. table 2-1. library function list function name description wmad_filedecodeinit decoder initialization processing wmad_filedecodedata decode processing wmad_filegetpcm decode processing wmad_getversion version information acquisition wmad_filedecodeinfo file information acquisition the following function must also be provided by the user in order to operate the sAP77016-B11. table 2-2. user-defined function list function name description wmad_filecbgetdata input data acquisition function chapter 2 library specifications user?s manual u15683ej1v0um 16 2.2 application processing flow an example of the application processing flow is shown below. figure 2-1. application processing flow reception processing for data input from host interface, etc. input buffer input data function call function call pcm data ye s ye s no no serial output processing output buffer end initialization processing start decoder initialization processing wmad_filedecodeinit decode processing wmad_filedecodedata decode processing wmad_filegetpcm input data acquisition processing wmad_filecbgetdata end of file? number of acquired samples less than number requested? chapter 2 library specifications user ? s manual u15683ej1v0um 17 2.3 function specifications the specifications for calling each library function are as follows. 2.3.1 wmad_filedecodeinit function [classification] wma decoder initialization processing function [function name] wmad_filedecodeinit [summary of function] initializes the ram area and sets the parameters used by the sAP77016-B11. [format] call wmad_filedecodeinit [arguments] argument description r0l start address of user-defined wmad_filecbgetdata function r1 contents information acquisition 1: acquire 0: do not acquire r2l start address of structure storing contents information (x memory) [return value] return value description r0 error code (see 2.4 error information for error code details) [function] this function sets the parameters and initializes the ram area used by the sap77016- b11. if the bit stream data contains contents information, this information can be acquired. an area (structure) for storing contents information must be prepared beforehand (refer to table 2-7 members of contents information structure ). [registers used] r0, r1, r2, r3, r4, r5, r6, r7, dp0, dp1, dp2, dp3, dp4, dn0 [hardware resources] maximum stack level 5 maximum loop stack level 2 maximum number of repetitions 502 maximum number of cycles 5.5 10 4 [remark] because this function calls the wmad_filecbgetdata function, when using the call stack via the wmad_filecbgetdata function, the maximum stack level will increase by the amount of that call stack. note also that the maximum number of repetitions and maximum number of cycles depend on the number of repetitions and cycles of the wmad_filecbgetdata function. the values above are for when the wmad_filecbgetdata function of the sample source is used and each item of contents information is acquired as 40 characters. the maximum number of cycles may also differ depending on factors such as the number of characters in the acquired contents information and whether marker information is included or not. chapter 2 library specifications user ? s manual u15683ej1v0um 18 2.3.2 wmad_filedecodedata function [classification] wma decode processing function [function name] wmad_filedecodedata [summary of function] decodes the bit stream data and creates the data required for pcm data creation. [format] call wmad_filedecodedata [arguments] none [return value] return value description r0 error code (see 2.4 error information for error code details) [function] this function decodes the bit stream data and stores the data required for pcm data creation in the static area. when decoding has finished, the error code cwma_failed or cwma_nomoreframes is returned. note that it is not necessary to subsequently execute the wmad_filegetpcm function when the error code is not cwma_noerr. this function should be re-executed only after the wmad_filegetpcm function is executed and all the pcm data that can be created at that time is created. [registers used] r0, r1, r2, r3, r4, r5, r6, r7, dp0, dp1, dp2, dp3, dp4, dp5, dp6, dp7, dn0, dn1, dn2, dn4, dn5, dn6, dn7 [hardware resources] maximum stack level 7 maximum loop stack level 2 maximum number of repetitions 25 maximum number of cycles 2.7 10 6 [remark] because this function calls the wmad_filecbgetdata function, when using the call stack via the wmad_filecbgetdata function, the maximum stack level will increase by the amount of that call stack. note also that the maximum number of repetitions and maximum number of cycles depend on the number of repetitions and cycles of the wmad_filecbgetdata function. the values above are for when the wmad_filecbgetdata function of the sample source is used. chapter 2 library specifications user ? s manual u15683ej1v0um 19 2.3.3 wmad_filegetpcm function [classification] wma decode processing function [function name] wmad_filegetpcm [summary of function] creates pcm data from the results of decoding wmad_filedecodedata. [format] call wmad_filegetpcm [arguments] argument description r0l start address of output buffer (x memory) r1l number of requested pcm samples (per channel) [return value] return value description r1 number of acquired pcm samples (per channel) [function] this function converts the decoding results stored in the static area into pcm-format data and stores pcm data totaling the number of requested pcm samples multiplied by the number of channels in the specified buffer in the x memory. in the case of 2-channel data, data is stored alternately in the order of l channel then r channel. for the argument indicating the number of requested pcm samples, specify a value that is either the same as or smaller than the pcm buffer size (but at least 1). if the return value indicating the number of acquired pcm samples is smaller than the number of requested pcm samples, it indicates that decoding of all the data stored in the static area has finished. to acquire the next pcm data, re-execute the wmad_filedecodedata function. note that the size of the user-defined output buffer can be reduced by reducing the number of requested pcm samples. [registers used] r0, r1, r2, r3, r4, r5, r6, r7, dp0, dp1, dp2, dp3, dp4, dp5, dn0, dn2, dn5, dn7 [hardware resources] maximum stack level 4 maximum loop stack level 1 maximum number of repetitions 0 maximum number of cycles 2.1 10 5 [remark] the maximum number of cycles is the value when the number of acquired pcm samples per channel is 2048. chapter 2 library specifications user?s manual u15683ej1v0um 20 2.3.4 wmad_getversion function [classification] version information acquisition function [function name] wmad_getversion [summary of function] returns the versions of the library and corresponding windows media player. [format] call wmad_getversion [arguments] none [return value] return value description r0h major version number of this library r0l minor version number of this library r1h major version number of the corresponding windows media player r1l minor version number of the corresponding windows media player [function] this function returns the version number of this library and the version number of the corresponding windows media player as a 32-bit value. example when r0 = 0x00?0x0001?0x0100, the library version is v1.01 when r1 = 0x00?0x0007?0x0000, the windows media player version is v7.0 [registers used] r0, r1 [hardware resources] maximum stack level 0 maximum loop stack level 0 maximum number of repetitions 0 maximum number of cycles 10 chapter 2 library specifications user ? s manual u15683ej1v0um 21 2.3.5 wmad_filedecodeinfo function [classification] file information acquisition function [function name] wmad_filedecodeinfo [summary of function] acquires wma file information. [format] call wmad_filedecodeinfo [arguments] argument description r0l start address of structure storing file information (x memory) [return value] return value description r0 error code (see 2.4 error information for error code details) [function] this function acquires file information such as the bit rate and sampling frequency and stores the result in the file information structure. execute this function after executing the wmad_filedecodeinit function. note that at this time an area (structure) for storing file information must be prepared in the x memory beforehand using the start address of that area as the argument. refer to table 2-6 members of file information structure for details of the structure for storing file information. [registers used] r0, r1, r2, dp0 [hardware resources] maximum stack level 0 maximum loop stack level 0 maximum number of repetitions 0 maximum number of cycles 41 chapter 2 library specifications user ? s manual u15683ej1v0um 22 2.3.6 wmad_filecbgetdata function (user-defined function) [classification] input data acquisition function [function name] wmad_filecbgetdata [summary of function] supplements the input buffer with the bit stream data required for decoding. [format] the wmad_filedecodeinit and wmad_filedecodedata functions call this function in call dp0 format. [arguments] argument description r0 size of requested data [bytes] r1 offset from start of bit stream data [bytes] [return value] return value description r0 size of acquired data [bytes] r2l start address of input buffer [function] this function is called from the wmad_filedecodeinit and wmad_filedecodedata functions a number of times each to supplement the input buffer with the bit stream data required for wma decoding. set the start address of this function using the wmad_filedecodeinit function. [usable registers] r0, r1, r2, r3, r4, r5, dp0, dp1 caution when using registers other than the above, be sure to save their contents to memory before use. [usable hardware resources] stack level 0 to 7 loop stack level 1 [remark] when using the repeat instruction in this function, the interrupt servicing may be delayed if the number of repetitions is large. similarly, if the number of execution cycles of this function is large, decoding may not be able to be performed in real time. also, be sure to set the stack level of this function so that the total stack level of the wmad_filecbgetdata function, wmad_filedecodedata function, and other functions used by the user does not exceed 15. chapter 2 library specifications user?s manual u15683ej1v0um 23 [function request specifications] ? store data of the requested size (argument: r0 bytes) in the user-defined input buffer in the x memory starting from the position of the offset from the start of the bit stream data (argument: r1 byte number), and set the size of the acquired data to the r0 register and the start address of the input buffer to the r2l register (refer to figure 2-2 setting data in input buffer ). the input buffer that stores the bit stream data must have a capacity of at least 64 words (128 bytes) (refer to 2.5 memory configuration ). ? the value of the r0 argument is between 1 and 128 (inclusive) when acquiring the data required for decoding. when this value exceeds 128, bit stream data not required for decoding is skipped, so data does not need to be set in the input buffer. be sure, however, to set the acquired data size for the r0 return value. ? the value of the r1 argument is always higher than the value of r1 when the wmad_filecbgetdata function was previously called. the r1 value when the wmad_filecbgetdata function is first called is 0. therefore bit stream data up to the value of r1 when the wmad_filecbgetdata function was previously called is always completely decoded. ? when the value of the r1 argument is equal to or lower than the terminal position (value of previous argument r1 + r0) of the bit stream data read when the wmad_filecbgetdata function was previously called (case a), it is necessary to keep all but the first byte of the data previously set in the input buffer note . therefore, be sure to save all but the first byte of the data set in the input buffer when the wmad_filecbgetdata function was previously called until that function is next called. note that if the sAP77016-B11 is operating normally, the contents of the input buffer set by the user are never changed. note if the previous value of the r0 argument exceeded 128, case a will not occur. ? when the value of the r1 argument is higher than the terminal position (value of previous argument r1 + r0) of the bit stream data read when the wmad_filecbgetdata function was previously called, data in which the offset is less than the value of r1 is never used. chapter 2 library specifications user ? s manual u15683ej1v0um 24 figure 2-2. setting data in input buffer input bit stream data offset from start [bytes] 0x12 0x34 0x12 msb 0x34 lsb 0x56 * * * * * * * * * * 0x56 0x78 0x9a 04812 when arguments are offset = 8, requested size = 3 input buffer 0x34 msb 0x56 lsb 0x78 0x9a * * * * * * * * when arguments are offset = 9, requested size = 4 input buffer * * = any value * * = any value chapter 2 library specifications user ? s manual u15683ej1v0um 25 2.4 error information details of the error codes returned by the functions of the sAP77016-B11 are shown in the table below. table 2-3. error code list error value description cwma_noerr 0 normal cwma_failed 1 other abnormality cwma_badargument 2 initialization was not completed normally cwma_badasfheader 3 illegal asf header cwma_badpacketheader 4 illegal packet header cwma_brokenframe 5 not used cwma_nomoreframes 6 there is no data to be decoded cwma_badsamplingrate 7 not used cwma_badnumberofchannels 8 not used cwma_badversionnumber 9 not used cwma_badweightingmode 10 not used cwma_badpacketization 11 not used cwma_baddrmtype 12 not used cwma_drmfailed 13 not used cwma_drmunsupported 14 drm is not supported cwma_demoexpired 15 not used cwma_badstate 16 not used cwma_internal 17 internal error chapter 2 library specifications user ? s manual u15683ej1v0um 26 2.5 memory configuration the configuration of the data memory used by the sAP77016-B11, including details of the static area and how to secure area for buffers, is described here. with the sAP77016-B11, the scratch memory area and static memory area must be defined separately. the respective sizes of these areas are shown in table 2-4 memory size required for each bit rate . table 2-4. memory size required for each bit rate (1/2) x memory size [words] y memory size [words] bit rate [bps] sampling frequency [hz] number of channels wma codec version static_x1 static_x2 scratch static_y1 static_y2 scratch 192,000 48,000 2 8 741 0 1,572 8,192 4,096 0 192,000 44,100 2 7, 8 741 0 1,572 8,192 4,096 0 160,000 48,000 2 2, 7, 8 741 0 1,572 8,192 4,096 0 160,000 44,100 2 2, 7, 8 741 0 1,572 8,192 4,096 0 128,000 48,000 2 2, 7, 8 741 0 1,572 8,192 4,096 0 128,000 44,100 2 2, 7, 8 741 0 1,572 8,192 4,096 0 96,000 44,100 2 2, 7, 8 741 0 1,572 8,192 4,096 0 80,000 44,100 2 2, 7, 8 741 0 1,572 8,192 4,096 0 64,000 44,100 2 2, 7, 8 741 0 1,572 8,192 4,096 0 64,000 32,000 2 2 741 0 1,572 8,192 4,096 0 48,000 44,100 2 2, 8 741 0 1,572 8,192 4,096 0 48,000 32,000 2 2, 7, 8 741 0 1,572 8,192 4,096 0 44,000 32,000 2 2 972 0 1,572 8,192 4,096 0 40,000 32,000 2 2, 7, 8 972 0 1,572 8,192 4,096 0 36,000 32,000 2 2 972 0 1,572 8,192 4,096 0 32,000 44,100 2 8 972 0 1,572 8,192 4,096 0 48,000 44,100 1 8 741 0 1,572 8,192 2,048 0 32,000 44,100 1 2, 7, 8 741 0 1,572 8,192 2,048 0 32,000 32,000 2 2, 7, 8 972 0 1,572 8,192 4,096 0 32,000 32,000 1 2 972 0 1,572 8,192 2,048 0 32,000 22,050 2 2, 7, 8 741 0 1,572 8,192 2,048 0 22,000 32,000 2 2 972 8,192 1,572 8,192 4,096 299 22,000 22,050 2 2, 7 972 4,096 1,572 8,192 2,048 299 22,000 22,050 2 8 972 0 1,572 8,192 2,048 0 20,000 32,000 1 2, 7 972 4,096 1,572 8,192 2,048 299 20,000 32,000 1 8 972 0 1,572 8,192 2,048 0 20,000 22,050 2 2, 7 972 4,096 1,572 8,192 2,048 299 20,000 22,050 2 8 972 0 1,572 8,192 2,048 0 20,000 22,050 1 2, 7 972 2,048 1,572 8,192 1,024 299 20,000 22,050 1 8 972 0 1,572 8,192 1,024 0 20,000 16,000 2 2, 7, 8 972 2,048 1,572 8,192 1,024 299 chapter 2 library specifications user?s manual u15683ej1v0um 27 table 2-4. memory size required for each bit rate (2/2) x memory size [words] y memory size [words] bit rate [bps] sampling frequency [hz] number of channels wma codec version static_x1 static_x2 scratch static_y1 static_y2 scratch 16,000 22,050 1 2, 7 972 2,048 1,572 8,192 1,024 299 16,000 22,050 1 8 972 0 1,572 8,192 1,024 0 16,000 16,000 2 2, 7, 8 972 2,048 1,572 8,192 1,024 299 16,000 16,000 1 2, 7, 8 972 1,024 1,572 8,192 512 299 12,000 16,000 1 2, 7, 8 972 1,024 1,572 8,192 512 299 12,000 8,000 2 2, 7, 8 972 2,048 1,572 8,192 1,024 299 10,000 16,000 1 2, 7, 8 972 1,024 1,572 8,192 512 299 10,000 11,025 1 2, 7, 8 972 1,024 1,572 8,192 512 299 8,000 11,025 1 2, 7, 8 972 1,024 1,572 8,192 512 299 8,000 8,000 1 2, 7, 8 972 1,024 1,572 8,192 512 299 6,000 8,000 1 2, 7, 8 972 1,024 1,572 8,192 512 299 5,000 8,000 1 2, 7, 8 972 1,024 1,572 8,192 512 299 128 8,000 1 2, 7, 8 972 1,024 1,572 8,192 512 299 2.5.1 scratch area this is a memory area that can be freed up and used by the user when the sAP77016-B11 is not operating. note, however, that because the scratch area is used once more when the middleware starts operating again, if the user has set information in this area, the set information may be changed at this time. secure the scratch area under the label names wmad_lib_scratch_x and wmad_lib_scratch_y. it is not necessary to make align or at specifications. the size of the area differs depending on the supported bit rate. for details, refer to table 2-4 memory size required for each bit rate . be sure to make a public declaration for defined symbols. figure 2-3. example of securing scratch area public wmad_lib_scratch_x public wmad_lib_scratch_y ; when all bit rates are supported #define wmad_max_scratch_x_size 1572 #define wmad_max_scratch_y_size 299 _ _ wmad_lib_scratch_x xramseg wmad_lib_scratch_x: ds wmad_max_scratch_x_size; _ _ wmad_lib_scratch_y yramseg wmad_lib_scratch_ y : ds wmad_max_scratch_y_size; end chapter 2 library specifications user ? s manual u15683ej1v0um 28 2.5.2 static area this area is used to store data permanently. if this area is manipulated by the user following initialization processing, the normal operation of this library cannot be guaranteed. secure the static area under the label names wmad_lib_static_x1, wmad_lib_static_x2, wmad_lib_static_y1, and wmad_lib_static_y2. it is not necessary to make align or at specifications. the size of the area differs depending on the supported bit rate. for details, refer to table 2-4 memory size required for each bit rate . be sure to make a public declaration for defined symbols. figure 2-4. example of securing static area public wmad_lib_static_x1 public wmad_lib_static_x2 public wmad_lib_static_y1 public wmad_lib_static_y2 ; when all bit rates are supported #define wmad_max_static_x1_size 972 #define wmad_max_static_x2_size 8192 #define wmad_max_static_y1_size 8192 #define wmad_max_static_y2_size 4096 _ _ wmad_lib_static_x1 xramseg wmad_lib_static_x1: ds wmad_max_static_x1_size; _ _ wmad_lib_static_x2 xramseg wmad_lib_static_x2: ds wmad_max_static_x2_size; _ _ wmad_lib_static_y1 yramseg wmad_lib_static_y1: ds wmad_max_static_y1_size; _ _ wmad_lib_static_y2 yramseg wmad_lib_static_y2: ds wmad_max_static_y2_size; end chapter 2 library specifications user ? s manual u15683ej1v0um 29 2.5.3 i/o buffers in order for the sAP77016-B11 to perform decoding, an input buffer is required to input the bit stream data (x memory) and an output buffer is required to store the pcm data of the decoding results (x memory). any symbol name can be assigned to these buffers, providing names used by the sAP77016-B11 or other applications are not duplicated. figure 2-5. example of securing i/o buffers public input_buffer public host_in_buff public output_buffer public serial_out_buff i_o_buffer_x xramseg input_buffer: ds 64; host_in_buff: ds 1536; output_buffer: ds 4096; serial_out_buff: ds 4096; end the input buffer must have a capacity of at least 64 words and the size of the output buffer should be set to accord with the system configuration. recommended output buffer sizes are shown in table 2-5 recommended output buffer size . note that when performing decoding in real time, buffers such as an input data receive buffer to receive the bit stream data sent from the host cpu (x or y memory), and a serial output buffer to output pcm data to the dac (x or y memory) are required in addition to the i/o buffers used by the sAP77016-B11. the size of the serial output buffer must be equivalent to the buffer size shown in table 2-5 recommended output buffer size . set the size of the input data receive buffer to accord with the system configuration, based on the average amount of input data calculated from the equation below. for example, to store the input data required to obtain the output results of the recommended output buffer size 2 samples, the size of the input data receive buffer should be the average input data amount calculated using the equation below, with the appropriate value from table 2-5 recommended output buffer size as the number of output samples, 2 words. the average input data amount calculated in this way will reach a maximum value of 558 words when the bit rate is 192 kbps and the sampling frequency is 44.1 khz. average input data amount = [words] bit rate [kbps]/16 sampling frequency [khz] number of output samples note, however, that if data that includes video data is received in addition to audio data, there may be insufficient data in the buffer, even if a larger buffer is secured. to counter this problem, it is recommended to construct a system in which a command requesting input data can be sent from the dsp side to the cpu. chapter 2 library specifications user ? s manual u15683ej1v0um 30 table 2-5. recommended output buffer size size [words] sampling frequency [hz] mono stereo 8,000 512 1,024 11,025 512 1,024 16,000 512 1,024 22,050 1,024 2,048 32,000 2,048 4,096 44,100 2,048 4,096 48,000 2,048 4,096 chapter 2 library specifications user ? s manual u15683ej1v0um 31 2.5.4 structures the following structures must be prepared in order to acquire wma file information or contents information. (1) file information structure to acquire wma file information, prepare the following structure in the x memory and execute the wmad_filedecodeinfo function. table 2-6. members of file information structure item size [words] version of wma file format note 1 sampling frequency [hz] 1 number of channels 1 playback time [ms] 2 packet size [bytes] 2 offset to first packet [bytes] 2 offset to last packet [bytes] 2 use of drm 0: drm not used, 1: drm used 2 bit rate [bps] 2 note the sAP77016-B11 only supports data of version 2 of the wma file format. data encoded using wma codec version 2, 7, or 8 is version 2 of the wma file format. (2) contents information structure to acquire information such as the title of a track, prepare the following contents information structure and contents character string area in the x memory and execute the wmad_filedecodeinit function. table 2-7. members of contents information structure item size [words] maximum length of title character string [bytes] 1 maximum length of creator character string [bytes] 1 maximum length of writer character string [bytes] 1 maximum length of explanatory note character string [bytes] 1 maximum length of regulation character string [bytes] 1 start address of title character string area 1 start address of creator character string area 1 start address of writer character string area 1 start address of explanatory note character string area 1 start address of regulation character string area 1 specify the maximum length (requested number of characters) of the contents information as an even number. if the contents information of the bit stream data is less than the requested number of characters, the length of the character string actually acquired (including the terminal code ? 0x0000 ? ) is stored as the maximum length of the character string in the structure. user?s manual u15683ej1v0um 32 chapter 3 installation 3.1 installation procedure install the sAP77016-B11 (wma decoder middleware) in the host machine following the procedure shown below. (1) create a work directory in the host machine. (2) copy all the files and directories on the supplied medium to the work directory in the host machine. 3.2 sample creation procedure an example of how to build the sample program of the sAP77016-B11 is shown below. (1) start up the wb77016 (workbench). (2) open the sample.prj project file. example select [project open project] and specify sample.prj. if the error ?cannot load system ~*.model? occurs, select [options processor model] and specify the appropriate model file. if the model file has been changed, change the constant data library file of the project to accord with the model file. example in the case of a model with rom, change wmad_ram.lib to wmad_rom.lib. (3) execute build and confirm that sample.lnk has been created. example the sample.lnk file is created by selecting [make build all]. chapter 3 installation user?s manual u15683ej1v0um 33 3.3 change of location the segment names used by the sAP77016-B11 are shown in table 3-1 segment names . the location can be changed to accord with the user?s target by separating the object files from the library files using the lb77016 (librarian) and utilizing the edit segment function of the wb77016 (workbench). note that this library and the static and scratch areas used by this library must not be allocated to external memory. table 3-1. segment names segment name description _ _wmad_imseg ? sAP77016-B11 instruction segment _ _wmad_xrom ? sAP77016-B11 x memory constant data segment _ _wmad_yrom ? sAP77016-B11 y memory constant data segment remark an asterisk (*) indicates an arbitrary alphanumeric character. 3.4 symbol naming conventions the conventions that apply when naming symbols used in this library are shown in table 3-2 naming conventions . take care not to duplicate names when using the sAP77016-B11 together with other applications. table 3-2. naming conventions classification convention function name, variable name wmad_xxxx segment name _ _wmad_xxxx (2 underscores at the start) remark xxxx indicates arbitrary alphanumeric characters. user?s manual u15683ej1v0um 34 chapter 4 system example 4.1 environment required for simulation using timing files the decode processing can be simulated by using the sample program and sample timing files. [example of software environment] ? high-speed simulator: hsm77016 ver.2.32 or later ? sample program: sample.lnk (program created in 3.2 sample creation procedure ) ? timing files: smp_input.tmg, smp_serout.tmg, clk_for_2ch.tmg ? input data file: xxx.dat (see 4.2 input data file creation for how to create this file) ? model file: upd77113.model (model file used when sample program was created) 4.2 input data file creation an input data file is required to perform simulation. create the input data file following the procedure shown below. (1) prepare arbitrary wma data (binary format). (2) convert the prepared wma data into a text file. in this text file, describe two bytes of wma data per line in order from the start of the data. figure 4-1. input data file wma data (binary format) offset from start [bytes] 0x12 0x34 0x1234 0x5678 0x9abc : : msb lsb 0x56 0x78 0x9a 0xbc 04812 input data text file (text format) chapter 4 system example user?s manual u15683ej1v0um 35 4.3 simulation an example of how to perform simulation is shown below. (1) edit the timing file to accord with the prepared input data file (refer to a.3 sample timing files ). (2) start up the hsm77016 (high-speed simulator). (3) select the model file in accordance with the target. example select [tools simulation model] and specify the model file. (4) open sample.lnk created in 3.2 sample creation procedure . example select [file open] and specify sample.lnk. (5) open the timing files smp_input.tmg, smp_serout.tmg, and clk_for_2ch.tmg. example select [file open] and specify each file. (6) reset the cpu and timing files of the hsm77016 (high-speed simulator). example select [run reset], specify all the items (cpu and built-in i/o devices, time measurement, all timing files and restart execution), and reset. (7) select run to execute. chapter 4 system example user ? s manual u15683ej1v0um 36 4.4 sample program outline 4.4.1 sample program the sample program of the sAP77016-B11 is designed based on a system in which input data is transmitted to the dsp via a host interface. input data is transmitted sequentially from the start of the data in 16-bit units. the decode processing unit (number of samples) is the value indicated in table 2-5 recommended output buffer size . 4.4.2 user-defined functions an outline of the user-defined function sample source is shown below. [variables] (1) filecbgetdata_fp variable this variable is used to manage the number of bytes of input data received via the host interface. in this system, input data is received in 2-byte units, so this will always be an even number. the value of this variable, x, also means that the offset from the start of the first input data received via the host interface in the wmad_filecbgetdata function called this time is data of x and x + 1. note that the value of this variable is not ? the value of argument r1 + r0 when the wmad_filecbgetdata function was previously called ? . (2) read_ptr variable this variable is used to manage the position at which data starts to be read from the input data receive buffer when data is set in the input buffer. (3) write_ptr variable this variable is used to manage the position at which input data received via the host interface starts to be written to the input data receive buffer. figure 4-2. configuration of sample user-defined function buffer host_in_buffer read_ptr write_ptr 128 words input data receive buffer input_buffer 64 words input buffer chapter 4 system example user ? s manual u15683ej1v0um 37 [processing] the value of the filecbgetdata_fp variable is compared with the value r1 of the requested offset position and branching to the following label occurs depending on the result: branch to the case000 label if filecbgetdata_fp = r1 branch to the case001 label if filecbgetdata_fp < r1 branch to the case002 label if filecbgetdata_fp > r1 ? case000 label: branching to this label occurs if either of the first two bytes of input data received first via the host interface matches the requested offset data. the value of the write_ptr variable is then set to the read_ptr variable. the size of the data to be received via the host interface in the processing following the get_data label is also set, and the program jumps to the get_data label. ? case001 label: branching to this label occurs if data in front of the input data already received is requested. in this case, the data up to the requested offset data is received via the host interface. the data received here is not used and is therefore not saved in the input data receive buffer. the value of the write_ptr variable is then set to the read_ptr variable. the size of the data to be received is also set, and the program jumps to the get_data label. ? case002 label: branching to this label occurs if the requested offset data has already been received. in this case, the read_ptr variable is set, but because the data already received is set in the input buffer, the position that is the value of the write_ptr variable rewound by the required number is set. next, if data of the requested size can be set in the input buffer from the data already received, the program jumps to the set_data label, and if data of the requested size cannot be set in the input buffer from the data already received, a new receive data size is set and the program jumps to the get_data label. ? get_data label: if the requested size is 128 bytes or less, the program jumps to the get_data_next label. in other cases, input data is received via the host interface, but this data is not used and is therefore not saved in the receive buffer. when the receive processing is finished, the program jumps to the finish label. ? get_data_next label: if the size of the data that should be received is 0, the program jumps to the set_data label. in other cases, the input data is received via the host interface and stored from the position indicated by the write_ptr variable. when the receive processing is finished, the write_ptr variable is updated and the program performs set_data label processing. ? set_data label: the input data stored in the input data receive buffer is read out from the position indicated by the read_ptr variable and set in the input buffer in accordance with the requested conditions. the program then performs finish label processing. ? finish label: after processing such as setting the return values and updating the filecbgetdata_fp variable is finished, the program returns to the caller from the wmad_filecbgetdata function processing. chapter 4 system example user ? s manual u15683ej1v0um 38 4.5 sample program processing flow the sample program processing flow is shown below. figure 4-3. initialization and decode processing flow initialization of registers, user variables, etc. start start of decode processing end to decode processing version information acquisition processing wmad_getversion decoder initialization processing contents information acquisition processing wmad_filedecodeinit file information acquisition processing wmad_filedecodeinfo decode processing unit setting predecode processing serial output start processing main decode processing decode end processing chapter 4 system example user ? s manual u15683ej1v0um 39 figure 4-4. predecode processing flow ye s ye s ye s error processing to serial output start processing to decode end processing ye s no start of predecode processing output buffer data copied to serial output buffer requested sample number, output buffer address setting any errors? acquired sample number = 0? decode processing wmad_filedecodedata no end of file? decode processing wmad_filegetpcm no no has data equal to the processing unit been output? chapter 4 system example user ? s manual u15683ej1v0um 40 figure 4-5. main decode processing flow ye s ye s ye s ye s start of main decode processing to decode end processing output buffer data copied to serial output buffer requested sample number, output buffer address setting acquired sample number = 0? decode processing wmad_filegetpcm no no no has data equal to the processing unit been output? ye s is the serial output buffer empty? no any errors? decode processing wmad_filedecodedata error processing no end of file? user?s manual u15683ej1v0um 41 appendix a sample program source the sample program source of the sAP77016-B11 is shown in this chapter. a.1 sample source files a.1.1 sample.asm this file is used to control the overall decode processing. /*-----------------------------------------------------------------*/ /* file information */ /*-----------------------------------------------------------------*/ /* name : sample.asm */ /* type : assembler program module */ /* version : 1.00 */ /* date : 2001 july 10 */ /* cpu : upd7701x family */ /* assembler : wb77016 ver 2.4 */ /* about : sample main function */ /* */ /*-----------------------------------------------------------------*/ /* copyright (c) nec corporation 2000, 2001 */ /* all rights reserved by nec corporation. */ /* use of copyright notice does not evidence publication */ /*-----------------------------------------------------------------*/ /* =============================================================== * include files * ============================================================= */ #include "wma_dec.h" /* =============================================================== * public * ============================================================= */ public num_channels ; for timing file public sample_rate ; for timing file /* =============================================================== * extern functions * ============================================================= */ extrn init_filecbgetdata extrn wmad_filecbgetdata (1/13) appendix a sample program so urce user ? s manual u15683ej1v0um 42 /* =============================================================== * define & equ * ============================================================= */ #define use_so 1 ; use serial output interrupt #define string_size 64 #define max_pcmsize 2048 max_ringsize equ max_pcmsize*2 /* =============================================================== * local variables and buffer * ============================================================= */ _ _ sample_x_ram xramseg ring_dn0: ds 1 ; ring_write_ptr: ds 1 ; ring_read_ptr: ds 1 ; ring_entries: ds 1 ; putin_temp: ds 2 ; save_regs: ds 6 ; g_uloutputsample: ds 2 ; start_flag: ds 1 ; n_sample: ds 1 ; f_dec_unit_end: ds 1 ; n_get_pcm: ds 1 ; _ _ sample_x_contents xramseg /***************************************************** contents information *****************************************************/ desc: desc_title_len: ds 1 ; desc_author_len: ds 1 ; desc_copyright_len: ds 1 ; desc_description_len: ds 1 ; desc_rating_len: ds 1 ; desc_ptitle: ds 1 ; desc_pauthor: ds 1 ; desc_pcopyright: ds 1 ; desc_pdescription: ds 1 ; desc_prating: ds 1 ; title: ds string_size/2 ; author: ds string_size/2 ; copyright: ds string_size/2 ; description: ds string_size/2 ; rating: ds string_size/2 ; structfileinfo: version: ds 1 ; (2/13) appendix a sample program so urce user ? s manual u15683ej1v0um 43 sample_rate: ds 1 ; num_channels ds 1 ; duration: ds 2 ; packet_size: ds 2 ; first_packet_offset: ds 2 ; last_packet_offset: ds 2 ; has_drm: ds 2 ; bit_rate: ds 2 ; _ _ sample_x_dec_output xramseg output_buffer: ds max_pcmsize*2 ; _ _ sample_x_ser_output xramseg align at 0 ser_out_buffer: ds max_ringsize ; /* =============================================================== * vector registration * ============================================================= */ main_v imseg at 0x200 jmp star ; regist start up routine nop ; nop ; nop ; ; reserve vector 1 nop ; reti ; nop ; nop ; ; reserve vector 2 nop ; reti ; nop ; nop ; ; reserve vector 3 nop ; reti ; nop ; nop ; ; int1 vector nop ; reti ; nop ; nop ; (3/13) appendix a sample program so urce user ? s manual u15683ej1v0um 44 ; int2 vector nop ; reti ; nop ; nop ; ; int3 vector nop ; reti ; nop ; nop ; ; int4 vector nop ; reti ; nop ; nop ; ; si1 vector nop ; reti ; nop ; nop ; ; so1 vector jmp _so_interrupt ; regist so1 handler reti ; nop ; nop ; ; si2 vector nop ; reti ; nop ; nop ; ; so2 vector nop ; reti ; nop ; nop ; ; hi vector nop ; reti ; nop ; nop ; ; ho vector nop ; (4/13) appendix a sample program so urce user ? s manual u15683ej1v0um 45 reti ; nop ; nop ; ; hardware signal vector nop ; reti ; nop ; nop ; ; timer vector nop ; reti ; nop ; nop ; /* =============================================================== * program code * ============================================================= */ main imseg at 0x240 ; start: clr(r0) ; r0l = eir ; r0 = r0 | 0x8000 ; eir = r0l ; disable interrupt ;;=========================================================;; ;; clear register ;;=========================================================;; clr(r0) ; clr(r1) ; clr(r2) ; clr(r3) ; clr(r4) ; clr(r5) ; clr(r6) ; clr(r7) ; dp0 = r0l ; dp1 = r0l ; dp2 = r0l ; dp3 = r0l ; dp4 = r0l ; dp5 = r0l ; dp6 = r0l ; dp7 = r0l ; dn0 = r0l ; dn1 = r0l ; dn2 = r0l ; dn3 = r0l ; (5/13) appendix a sample program so urce user ? s manual u15683ej1v0um 46 dn4 = r0l ; dn5 = r0l ; dn6 = r0l ; dn7 = r0l ; dmx = r0l ; dmy = r0l ; ;;=========================================================;; ;; initialize register & peripheral units ;;=========================================================;; r0l = 0x0000 ; *dwtr:x=r0l ; r0l = 0x0081 ; *hst:x = r0l ; r0l = 0x0202 ; *sst1:x = r0l ; ;;=========================================================;; ;; initialize variables and buffer ;;=========================================================;; dp0 = ser_out_buffer ; clr(r0) ; rep max_ringsize ; *dp0++ = r0h ; r0l = ser_out_buffer ; *ring_write_ptr:x = r0l ; *ring_read_ptr:x = r0l ; *ring_entries:x = r0h ; set 0 r0l = 1 ; *ring_dn0:x = r0l ; *g_uloutputsample:x = r0h ; *g_uloutputsample+1:x = r0h ; r0l = title ; *desc_ptitle:x = r0l ; r0l = author ; *desc_pauthor:x = r0l ; r0l = copyright ; *desc_pcopyright:x = r0l ; r0l = description ; *desc_pdescription:x = r0l ; r0l = rating ; *desc_prating:x = r0l ; r0l = string_size ; *desc_title_len:x = r0l ; *desc_author_len:x = r0l ; *desc_copyright_len:x = r0l ; (6/13) appendix a sample program so urce user ? s manual u15683ej1v0um 47 *desc_description_len:x = r0l ; *desc_rating_len:x = r0l ; call init_filecbgetdata ; ;;=========================================================;; ;; get version information ;;=========================================================;; call wmad_getversion ; ;;=========================================================;; ;; initialize wma decoder and get content information ;;=========================================================;; r0l = wmad_filecbgetdata ; clr(r1) ; r1l = 0x0001 ; r2l = desc ; call wmad_filedecodeinit ; r0 = r0 ^ cwma_noerr ; if(r0!=0) jmp _init_error ; ;;=========================================================;; ;; get file information ;;=========================================================;; r0l = structfileinfo ; call wmad_filedecodeinfo ; ;;=========================================================;; ;; set size of unit for decode process ;;=========================================================;; clr(r0) ; r0l = *sample_rate:x ; r1 = r0 - 32000 ; if(r1>=0) jmp _pre_set_size_2048 ; r1 = r0 - 22050 ; if(r1>=0) jmp _pre_set_size_1024 ; r1l = 512 ; jmp _pre_set_size_end ; _pre_set_size_1024: r1l = 1024 ; jmp _pre_set_size_end ; _pre_set_size_2048: r1l = 2048 ; _pre_set_size_end: *n_sample:x = r1l ; sample per ch clr(r0) ; *start_flag:x = r0l ; set *start_flag:x = 0 (7/13) appendix a sample program so urce user ? s manual u15683ej1v0um 48 *f_dec_unit_end:x = r0l ; *n_get_pcm:x = r0l ; ;;=========================================================;; ;; previous decode routine ;;=========================================================;; _pre_decodedata: call wmad_filedecodedata ; /*** decode is finished ? ***/ r1 = r0 ^ cwma_nomoreframes ; if(r1==0) jmp finish ; r1 = r0 ^ cwma_failed ; if(r1==0) jmp finish ; /*** check error ***/ r1 = r0 ^ cwma_noerr ; if(r1!=0) jmp _decode_error ; _pre_getpcm: r2 = *n_get_pcm:x ; r3 = *n_sample:x ; r1 = r3 - r2 ; r1 = r1 sra 16 ; set r1 r2 = r2 sra 16 ; clr(r4) ; r4l = *num_channels:x ; set r4 = number of ch r4 = r4 - 2 ; if(r4==0) r2 += r2 ; r0l = output_buffer ; r0 = r0 + r2 ; set r0 call wmad_filegetpcm ; if(r1==0) jmp _pre_decodedata ; clr(r2) ; r2h= *g_uloutputsample:x ; r2l= *g_uloutputsample+1:x ; r2 = r2 + r1 ; count total sample per ch *g_uloutputsample:x = r2h ; *g_uloutputsample+1:x = r2l ; clr(r2) ; r2l = *n_get_pcm:x ; r2 = r2 + r1 ; clr(r3) ; r3l = *n_sample:x ; r3 = r3 - r2 ; if(r3>0) jmp _pre_getpcm_end ; (8/13) appendix a sample program so urce user ? s manual u15683ej1v0um 49 r2l = 1 ; *f_dec_unit_end:x = r2l ; f_dec_unit_end = 1 *start_flag:x = r2l ; set *start_flag:x = 1 clr(r2) ; _pre_getpcm_end: *n_get_pcm:x = r2l ; /* chekc decode unit is end ? */ r2 = *f_dec_unit_end:x ; if(r2==0) jmp _pre_getpcm ; #if use_so call _setpcm ; set pcm #else *f_dec_unit_end:x = r2l ; f_dec_unit_end = 0 #endif ;;=========================================================;; ;; set interrupt mask and start serial output ;;=========================================================;; serout_start: *sdt1:x = r1h ; serial out start r0l = sr ; r0 = r0 & 0x7fdf ; r0 = r0 | 0x0fdf ; nop ; sr = r0l ; enable interrupt (so1) jmp _loop_getpcm ; ;;=========================================================;; ;; main routine ;;=========================================================;; _loop_decodedata: call wmad_filedecodedata ; /*** decode is finished ? ***/ r1 = r0 ^ cwma_nomoreframes ; if(r1==0) jmp finish ; r1 = r0 ^ cwma_failed ; if(r1==0) jmp finish ; /*** check error ***/ r1 = r0 ^ cwma_noerr ; if(r1!=0) jmp _decode_error ; r1 = *ring_entries:x ; if(r1<0) jmp _mips_overflow ; _loop_getpcm: r2 = *n_get_pcm:x ; (9/13) appendix a sample program so urce user ? s manual u15683ej1v0um 50 r3 = *n_sample:x ; r1 = r3 - r2 ; r1 = r1 sra 16 ; set r1 r2 = r2 sra 16 ; clr(r4) ; r4l = *num_channels:x ; set r4 = number of ch r4 = r4 - 2 ; if(r4==0) r2 += r2 ; r0l = output_buffer ; r0 = r0 + r2 ; set r0 call wmad_filegetpcm ; r2 = *ring_entries:x ; if(r2<0) jmp _mips_overflow ; if(r1==0) jmp _loop_decodedata ; clr(r2) ; r2h= *g_uloutputsample:x ; r2l= *g_uloutputsample+1:x ; r2 = r2 + r1 ; count total sample per ch *g_uloutputsample:x = r2h ; *g_uloutputsample+1:x = r2l ; clr(r2) ; r2l = *n_get_pcm:x ; r2 = r2 + r1 ; clr(r3) ; r3l = *n_sample:x ; r3 = r3 - r2 ; if(r3>0) jmp _loop_getpcm_end ; r2l = 1 ; *f_dec_unit_end:x = r2l ; f_dec_unit_end = 1 clr(r2) ; _loop_getpcm_end: *n_get_pcm:x = r2l ; /* check decode unit is end ? */ r2 = *f_dec_unit_end:x ; if(r2==0) jmp _loop_getpcm ; nop ; _loop_wait: r2 = *ring_entries:x ; if(r2<0) jmp _mips_overflow ; if(r2!=0) jmp _loop_wait ; #if use_so call _setpcm ; set pcm #else *f_dec_unit_end:x = r2l ; f_dec_unit_end = 0 #endif (10/13) appendix a sample program so urce user ? s manual u15683ej1v0um 51 jmp _loop_getpcm ; ;;=========================================================;; ;; finish ;;=========================================================;; finish: r2 = *ring_entries:x ; if(r2>0) jmp $-1 ; r2 = *n_get_pcm:x ; if(r2==0) jmp serout_finish ; *n_sample:x = r2h ; #if use_so call _setpcm ; set pcm #else *f_dec_unit_end:x = r2l ; f_dec_unit_end = 0 #endif r2 = *ring_entries:x ; if(r2>0) jmp $-1 ; serout_finish: nop ; jmp serout_finish ; ;;=========================================================;; ;; error ;;=========================================================;; _init_error: nop ; jmp $-1 ; _decode_error: nop ; jmp $-1 ; _mips_overflow: nop ; jmp $-1 ; /* =============================================================== [function name] _setpcm ===============================================================*/ _setpcm: dp0 = output_buffer ; r2l = *ring_write_ptr:x ; dp1 = r2l ; dn1 = 1 ; (11/13) appendix a sample program so urce user ? s manual u15683ej1v0um 52 dmx = max_ringsize-1 ; clr(r4) ; r4l = *num_channels:x ; set r4 = number of ch r4 = r4 - 1 ; clr(r3) ; r3l = *n_sample:x ; loop r3l { ; r2 = *dp0++ ; *dp1%% = r2h ; if(r4==0) jmp $+2 ; if ch = 1 r2 = *dp0++ ; *dp1%% = r2h ; nop ; }; r2l = dp1 ; *ring_write_ptr:x = r2l ; r3 += r3 ; always, output 2 ch clr(r2) ; *f_dec_unit_end:x = r2h ; f_dec_unit_end = 0 r2l = eir ; r2 = r2 | 0x8000 ; eir = r2l ; nop ; nop ; wait disable interrupt nop ; r2l = *ring_entries:x ; r2 = r2 + r3 ; *ring_entries:x = r2l ; r2l = eir ; r2 = r2 & 0x7fff ; eir = r2l ; enable interrupt ret ; /* =============================================================== [handler name] _so_interrupt: ===============================================================*/ _so_interrupt: *save_regs+0:x = r0l ; push r0 *save_regs+1:x = r0h ; *save_regs+2:x = r0e ; r0l = dp0 ; *save_regs+3:x = r0l ; push dp0 r0l = dn0 ; *save_regs+4:x = r0l ; push dn0 r0l = dmx ; *save_regs+5:x = r0l ; push dmx (12/13) appendix a sample program so urce user ? s manual u15683ej1v0um 53 r0l = *ring_read_ptr: ; dp0 = r0l ; set dp0 r0l = *ring_dn0:x ; dn0 = r0l ; set dn0 dmx = max_ringsize-1 ; set dmx r0 = *dp0%% ; *sdt1:x=r0h ; set output pcm data r0l = dp0 ; *ring_read_ptr:x = r0l ; set read ptr r0l = *ring_entries:x ; r0 = r0 - 1 ; *ring_entries:x = r0l ; set ring_entries r0l = *save_regs+5:x ; dmx = r0l ; pop dmx r0l = *save_regs+4:x ; dn0 = r0l ; pop dn0 r0l = *save_regs+3:x ; dp0 = r0l ; pop dp0 r0e = *save_regs+2:x ; r0h = *save_regs+1:x ; r0l = *save_regs+0:x ; pop r0 reti ; end (13/13) appendix a sample program so urce user ? s manual u15683ej1v0um 54 a.1.2 smp_data.asm this file is used to secure the static and scratch areas. /* =============================================================== * public * ============================================================= */ public wmad_lib_static_x1 public wmad_lib_static_x2 public wmad_lib_static_y1 public wmad_lib_static_y2 public wmad_lib_scratch_x public wmad_lib_scratch_y /* =============================================================== * static memory * ============================================================= */ _ _ wmad_lib_static_x1 xramseg wmad_lib_static_x1: ds 972 _ _ wmad_lib_static_x2 xramseg wmad_lib_static_x2: ds 4096 _ _ wmad_lib_static_y1 yramseg wmad_lib_static_y1: ds 8192 _ _ wmad_lib_static_y2 yramseg wmad_lib_static_y2: ds 4096 /* =============================================================== * scratch memory * ============================================================= */ _ _ wmad_lib_scratch_x xramseg wmad_lib_scratch_x: ds 1600 _ _ wmad_lib_scratch_y yramseg wmad_lib_scratch_y: ds 300 end appendix a sample program so urce user ? s manual u15683ej1v0um 55 a.1.3 smp_user.asm this file is the source file of the user-defined function wmad_filecbgetdata. /*-----------------------------------------------------------------*/ /* file information */ /*-----------------------------------------------------------------*/ /* name : smp_user.asm */ /* type : assembler program module */ /* version : 1.00 */ /* date : 2001 jun 18 */ /* cpu : upd7701x family */ /* assembler : wb77016 ver 2.4 */ /* about : wmad_filecbgetdata function */ /* */ /*-----------------------------------------------------------------*/ /* copyright (c) nec corporation 2000, 2001 */ /* all rights reserved by nec corporation */ /* use of copyright notice does not evidence publication */ /*-----------------------------------------------------------------*/ /* =============================================================== * include files * ============================================================= */ #include "wma_dec.h" /* =============================================================== * public functions * ============================================================= */ public init_filecbgetdata public wmad_filecbgetdata /* =============================================================== * extern functions * ============================================================= */ /* =============================================================== * define * ============================================================= */ #define cw_buff_size 64 #define cb_buff_size 128 /* =============================================================== * local memory * ============================================================= */ (1/6) appendix a sample program so urce user ? s manual u15683ej1v0um 56 _ _ smp_user_xram_ _ xramseg filecbgetdata_fp: ds 2 ; size of obtained bitstream data [byte] read_ptr: ds 1 ; read pointer to host_in_buffer write_ptr: ds 1 ; write pointer to host_in_buffer tmp_dn0: ds 1 ; for saving value of dn0 register tmp_dmx: ds 1 ; for saving value of dmx register _ _ smp_user_buffer_ _ xramseg align at 0 host_in_buffer: ds cw_buff_size*2 ; buffer for input data from host i/f input_buffer: ds cw_buff_size ; buffer for input data to middle ware /* =============================================================== * program code * ============================================================= */ _ _ smp_user_ _ imseg /* =============================================================== [function name] init_filecbgetdata [argument] r0 : data size [return] non [call function] non [use register] r0, dp0, dp1 [use stacks] loop stack: 1, call stack: 0, repeat: 0 ===============================================================*/ init_filecbgetdata: clr(r0) ; *filecbgetdata_fp+0:x = r0l ; *filecbgetdata_fp+1:x = r0l ; dn0 = r0l ; r0l = host_in_buffer ; *read_ptr:x = r0l ; *write_ptr:x = r0l ; dp0 = r0l ; r0l = input_buffer ; dp1 = r0l ; loop cw_buff_size { ; clear buffer *dp0++ = r0h ; *dp0++ = r0h ; *dp1++ = r0h ; } ; ret ; (2/6) appendix a sample program so urce user ? s manual u15683ej1v0um 57 /* =============================================================== [function name] wmad_filecbgetdata [argument] r0 : required size [byte] r1 : offset [byte] [return] r0 : obtained size [byte] r2l : address of input buffer [call function] non [use register] r0, r1, r2, r3, r4, r5, r6 dp0, dp1, dn0, dmx [use stacks] loop stack: 1, call stack: 0, repeat: 0 ===============================================================*/ wmad_filecbgetdata: r4l = dn0 ; *tmp_dn0:x = r4l ; r4l = dmx ; *tmp_dmx:x = r4l ; r4l = 1 ; dn0 = r4l ; r4l = 2*cw_buff_size - 1 ; dmx = r4l ; r5 = *filecbgetdata_fp+0:x ; r5l= *filecbgetdata_fp+1:x ; r5 is always even. r4 = r5-r1 ; if(r4==0) jmp case000 ; if(r4>0) jmp case002 ; ;;=========================================================;; ;; case001 ( r5 < r1 ) ;;=========================================================;; case001: r4 = -r4 ; r4 = r4 sra 1 ; r4 = read size [word] if(r4<=0) jmp case001a ; loop r4l { ; %read_host(r6,r6) ; r5 = r5 + 2 ; nop ; not stored } ; case001a: r6l = *write_ptr:x ; *read_ptr:x = r6l ; set read_ptr r3 = r0 + 1 ; r3 = r3 srl 1 ; set r3 = read size [word] jmp get_data ; (3/6) appendix a sample program so urce user ? s manual u15683ej1v0um 58 ;;=========================================================;; ;; case000 ( r5 = r1 ) ;;=========================================================;; case000: r6l = *write_ptr:x ; *read_ptr:x = r6l ; set read_ptr r3 = r0 + 1 ; r3 = r3 srl 1 ; set r3 = read size [word] jmp get_data ; ;;=========================================================;; ;; case002 ( r5 > r1 ) ;;=========================================================;; case002: r3 = r4 + 1 ; r3 = r3 sra 1 ; set r3 = rewind size [word] clr(r6) ; r6l= *write_ptr:x ; r6 = r6 - r3 ; r3 = r6 - host_in_buffer ; if(r3>=0) jmp case002a ; r6 = r3 + host_in_buffer + cb_buff_size; case002a: *read_ptr:x = r6l ; set read_ptr r3 = r0 - r4 ; if(r3<=0) jmp set_data ; no need to read data r3 = r3+1 ; r3 = r3 srl 1 ; set r3 = read size [word] ;;=========================================================;; ;; get data ;;=========================================================;; get_data: r4 = r0 - cb_buff_size ; if(r4<=0) jmp get_data_nex ; r3 = r0 + 1 ; r3 = r3 sra 1 ; loop r3l { ; %read_host(r4,r4) ; r5 = r5 + 2 ; nop ; not stored }; jmp finish ; (4/6) appendix a sample program so urce user ? s manual u15683ej1v0um 59 get_data_next: if(r3==0) jmp set_data ; r6l = *write_ptr:x ; dp0 = r6l ; loop r3l { %read_host(r4,r4) ; get data *dp0%% = r4h ; r5 = r5 + 2 ; } r6l = dp0 ; *write_ptr:x = r6l ; ;;=========================================================;; ;; set data ;;=========================================================;; set_data: r6l = *read_ptr:x ; dp0 = r6l ; dp1 = input_buffer ; r4 = r0+1 ; r4 = r4 srl 1 ; if(r4==0) jmp finish ; r3 = r1 & 1 ; if(r3==0) jmp simple_copy ; r3l= *dp0%% ; r3 = r3 sll 8 ; loop r4l { r3 = r3 sll 8 ; change allocation r3l= *dp0%% ; r3 = r3 sll 8 ; *dp1++ = r3h ; set data }; jmp finish ; simple_copy: loop r4l { ; r3l= *dp0%% ; *dp1++ = r3l ; set data }; ;;=========================================================;; ;; finish ;;=========================================================;; finish: *filecbgetdata_fp+0:x = r5h ; *filecbgetdata_fp+1:x = r5l ; (5/6) appendix a sample program so urce user ? s manual u15683ej1v0um 60 r4l = *tmp_dn0:x ; dn0 = r4l ; r4l = *tmp_dmx:x ; dmx = r4l ; r2l= input_buffer ; set r2l ret ; end (6/6) appendix a sample program so urce user ? s manual u15683ej1v0um 61 a.2 sample header file a.2.1 wma_dec.h this is the header file for the sample program. /*-----------------------------------------------------------------*/ /* file information */ /*-----------------------------------------------------------------*/ /* name : wma_dec.h */ /* type : assembler header file */ /* version : 1.00 */ /* date : 2001 jun 18 */ /* cpu : upd7701x family */ /* assembler : wb77016 ver 2.4 */ /* about : header file for sample source code */ /* */ /*-----------------------------------------------------------------*/ /* copyright (c) nec corporation 2000, 2001 */ /* all rights reserved by nec corporation. */ /* use of copyright notice does not evidence publication */ /*-----------------------------------------------------------------*/ /* =============================================================== * define * ============================================================= */ #define sdt1 0x3800 #define sst1 0x3801 #define sdt2 0x3802 #define sst2 0x3803 #define hdt 0x3806 #define hst 0x3807 #define dwtr 0x3808 /* =============================================================== * extern functions * ============================================================= */ extrn wmad_filedecodeinit extrn wmad_filedecodedata extrn wmad_filegetpcm extrn wmad_filedecodeinfo extrn wmad_getversion /* =============================================================== * macro * ============================================================= */ %define (read_host(x,y)) ( y@l = *hst:x ; y = y & 1 ; (1/2) appendix a sample program so urce user ? s manual u15683ej1v0um 62 if(y !=0) jmp $-2 ; x = *hdt:x ; ); /* =============================================================== * define (error code) * ============================================================= */ #define cwma_noerr 0 #define cwma_failed 1 #define cwma_badargument 2 #define cwma_badasfheader 3 #define cwma_badpacketheader 4 #define cwma_brokenframe 5 #define cwma_nomoreframes 6 #define cwma_badsamplingrate 7 #define cwma_badnumberofchannels 8 #define cwma_badversionnumber 9 #define cwma_badweightingmode 10 #define cwma_badpacketization 11 #define cwma_baddrmtype 12 #define cwma_drmfailed 13 #define cwma_drmunsupported 14 #define cwma_demoexpired 15 #define cwma_badstate 16 #define cwma_internal 17 (2/2) appendix a sample program so urce user ? s manual u15683ej1v0um 63 a.3 sample timing files a.3.1 smp_input.tmg this timing file fetches data from the input data file (sample_20_16s.dat) and inputs data via the host interface. the input data file name on the 10th line should be changed to accord with the input data file prepared by the user. ;;-----------------------------------------------------------------;; ;; declare variables ;;-----------------------------------------------------------------;; local data ; local variable receives data ;;-----------------------------------------------------------------;; ;; file open ;;-----------------------------------------------------------------;; open input "sample_20_16s.dat" output format showbase unsigned hex, ; select output format ;;------------------------------------------------------------------;; ;; init ;;------------------------------------------------------------------;; set pin hcs = 1 ; terminate any write access, which might set pin hwr = 1 ; be active set pin hrd = 1 ; ;;------------------------------------------------------------------;; ;; main input loop ;;------------------------------------------------------------------;; do ; wait cond pin hwe == 0 ; wait till write is allowed wait cond pin hcs == 1 ; and no read is in progress set pin hcs = 0 ; perform the access... set port ha = 0 ; select higher byte of hdt set pin hwr = 0 ; start input input data ; input host data to temp variable set port hd = data&0xff ; input low byte to host port wait 100ns ; access duration set pin hcs = 1 ; terminate first access... set pin hwr = 1 ; end output wait 5ns ; delay set port ha = 1 ; select higher byte of hdt wait 5ns ; delay set pin hwr = 0 ; start output (1/2) appendix a sample program so urce user ? s manual u15683ej1v0um 64 set pin hcs = 0 ; perform second access... set port hd = (data>>8)&0xff ; input high byte to host port wait 100ns ; access duration set pin hwr = 1 ; end input set pin hcs = 1 ; end access enddo ; ;;--------------------------------------------------------------------;; ;; file close ;;--------------------------------------------------------------------;; close input ; break ; end (2/2) appendix a sample program so urce user ? s manual u15683ej1v0um 65 a.3.2 smp_serout.tmg this timing file is used to save the 16-bit linear pcm data output from the serial interface to a file (so_sample_20_16s_l.dat, so_sample_20_16s_r.dat). set any name for the file names on the 9th and 10th lines. in the case of stereo data, l-channel and r-channel data is output to output files #1 and #2 respectively. in the case of monaural data, the same data is output to output files #1 and #2. ;;----------------------------------------------------------------------;; ;; initialize ;;----------------------------------------------------------------------;; set pin soen1 = 0 ; initialize soen1 line ;;----------------------------------------------------------------------;; ;; file open ;;----------------------------------------------------------------------;; open output #1 "so_sample_20_16s_l.dat" ; open output #2 "so_sample_20_16s_r.dat" ; open output #3 "dummy_serial.dat" ; output format showbase unsigned hex, ; select output format ;;----------------------------------------------------------------------;; ;; dummy output ;;----------------------------------------------------------------------;; if pin soen1 == 0 ; do only if new transmission start wait cond pin sorq1 == 1 ; wait for serial output request wait 5 ns ; logic delay set pin soen1 = 1 ; start serial output endif wait cond pin sorq1 == 0 ; wait for serial output start confirmation set pin soen1 = 0 ; rept 15 ; wait 15 clock cycles for one data frame wait cond pin sck1 == 0 ; wait for rising edge (0->1) wait cond pin sck1 == 1 ; endrept ; wait 5ns ; make sure so1 and sorq1 are updated output #3 port so1&0xffff ; write output data to file, mask sign bits if pin sorq1 == 1 ; request next output set pin soen1 = 1 ; start next serial output endif (1/3) appendix a sample program so urce user ? s manual u15683ej1v0um 66 wait cond pin sck1 == 0 ; wait for rising edge (0->1) wait cond pin sck1 == 1 ; close output #3 ;;----------------------------------------------------------------------;; ;; main output loop ;;----------------------------------------------------------------------;; do ; ;;----------------------------------------------------------------------;; ;; for ch 1 ;;----------------------------------------------------------------------;; if pin soen1 == 0 ; do only if new transmission start wait cond pin sorq1 == 1 ; wait for serial output request wait 5 ns ; logic delay set pin soen1 = 1 ; start serial output endif wait cond pin sorq1 == 0 ; wait for serial output start confirmation set pin soen1 = 0 ; rept 15 ; wait 15 clock cycles for one data frame wait cond pin sck1 == 0 ; wait for rising edge (0->1) wait cond pin sck1 == 1 ; endrept ; wait 5ns ; make sure so1 and sorq1 are updated output #1 port so1&0xffff ; write output data to file, mask sign bits if pin sorq1 == 1 ; request next output set pin soen1 = 1 ; start next serial output endif wait cond pin sck1 == 0 ; wait for rising edge (0->1) wait cond pin sck1 == 1 ; ;;----------------------------------------------------------------------;; ;; for ch 2 ;;----------------------------------------------------------------------;; if pin soen1 == 0 ; do only if new transmission start wait cond pin sorq1 == 1 ; wait for serial output request wait 5 ns ; logic delay set pin soen1 = 1 ; start serial output endif wait cond pin sorq1 == 0 ; wait for serial output start confirmation set pin soen1 = 0 ; (2/3) appendix a sample program so urce user ? s manual u15683ej1v0um 67 rept 15 ; wait 15 clock cycles for one data frame wait cond pin sck1 == 0 ; wait for rising edge (0->1) wait cond pin sck1 == 1 ; endrept ; wait 5ns ; make sure so1 and sorq1 are updated output #2 port so1&0xffff ; write output data to file, mask sign bits if pin sorq1 == 1 ; request next output set pin soen1 = 1 ; start next serial output endif wait cond pin sck1 == 0 ; wait for rising edge (0->1) wait cond pin sck1 == 1 ; ;;----------------------------------------------------------------------;; ;; serial output is finished ? ;;----------------------------------------------------------------------;; exit ip == (main.serout_finish & 0xffff) ; exit ip == ((main.serout_finish+1) & 0xffff) ; enddo ;;----------------------------------------------------------------------;; ;; file close ;;----------------------------------------------------------------------;; close output #1 ; close data file close output #2 ; close data file break ; end (3/3) appendix a sample program so urce user ? s manual u15683ej1v0um 68 a.3.3 clk_for_2ch.tmg this timing file creates the clock signals used to generate the serial output interrupt. create clock signals with an appropriate cycle in accordance with the input data sampling frequency. this file is described under the assumption that 2-channel data is always output. ;;----------------------------------------------------------------------;; ;; declare variables ;;----------------------------------------------------------------------;; local tm_pico_sec ; local fs ; local retern_addr ; ;;----------------------------------------------------------------------;; ;; wait ;;----------------------------------------------------------------------;; wait cond reg ip == ((main.serout_start) & 0xffff) ; ;;----------------------------------------------------------------------;; ;; set sampling frequency and tm_pico_sec ;;----------------------------------------------------------------------;; set fs = *sample_rate:x & 0xffff ; set tm_pico_sec = time_resolution / 16 / fs / 2 ; time_resolution = 10**12 ;;----------------------------------------------------------------------;; ;; generate clock for 2 ch ;;----------------------------------------------------------------------;; do wait (tm_pico_sec/2) ps ; set pin sck1 = 0 ; set pin sck2 = 0 ; wait (tm_pico_sec/2) ps ; set pin sck1 = 1 ; set pin sck2 = 1 ; enddo although nec has taken all possible steps to ensure that the documentation supplied to our customers is complete, bug free and up-to-date, we readily accept that errors may occur. despite all the care and precautions we've taken, you may encounter problems in the documentation. please complete this form whenever you'd like to report errors or suggest improvements to us. hong kong, philippines, oceania nec electronics hong kong ltd. fax: +852-2886-9022/9044 korea nec electronics hong kong ltd. seoul branch fax: +82-2-528-4411 taiwan nec electronics taiwan ltd. fax: +886-2-2719-5951 address north america nec electronics inc. corporate communications dept. fax: +1-800-729-9288 +1-408-588-6130 europe nec electronics (europe) gmbh market communication dept. fax: +49-211-6503-274 south america nec do brasil s.a. fax: +55-11-6462-6829 asian nations except philippines nec electronics singapore pte. ltd. fax: +65-250-3583 japan nec semiconductor technical hotline fax: +81- 44-435-9608 i would like to report the following error/make the following suggestion: document title: document number: page number: thank you for your kind support. if possible, please fax the referenced page or drawing. excellent good acceptable poor document rating clarity technical accuracy organization cs 01.11 name company from: tel. fax facsimile message |
Price & Availability of AP77016-B11
![]() |
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |