ETC AP77016-B01

User’s Manual
µSAP77016-B01
Acoustic Echo Canceller Middleware
Target Devices
µPD77015
µPD77016
µPD77017
µPD77018A
µPD77019
µPD77110
µPD77111
µPD77112
µPD77113
µPD77113A
µPD77114
µPD77115
Document No. U13130EJ4V0UM00 (4th edition)
Date Published June 2001 N CP(K)
Printed in Japan
[MEMO]
2
User’s Manual U13130EJ4V0UM
Windows is either a trademark or registered trademark of Microsoft Corporation in the United States and/or
other countries.
• The information in this document is current as of April, 2001. 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 property 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 property 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 before 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": Transportation 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).
M8E 00. 4
User’s Manual U13130EJ4V0UM
3
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.)
NEC Electronics (Germany) GmbH
NEC Electronics Hong Kong Ltd.
Santa Clara, California
Tel: 408-588-6000
800-366-9782
Fax: 408-588-6130
800-729-9288
Benelux Office
Eindhoven, The Netherlands
Tel: 040-2445845
Fax: 040-2444580
Hong Kong
Tel: 2886-9318
Fax: 2886-9022/9044
NEC Electronics Hong Kong Ltd.
Velizy-Villacoublay, France
Tel: 01-3067-5800
Fax: 01-3067-5899
Seoul Branch
Seoul, Korea
Tel: 02-528-0303
Fax: 02-528-4411
NEC Electronics (France) S.A.
NEC Electronics Singapore Pte. Ltd.
Milton Keynes, UK
Tel: 01908-691-133
Fax: 01908-670-290
Madrid Office
Madrid, Spain
Tel: 091-504-2787
Fax: 091-504-2860
Novena Square, Singapore
Tel: 253-8311
Fax: 250-3583
NEC Electronics Italiana s.r.l.
NEC Electronics (Germany) GmbH
Milano, Italy
Tel: 02-66 75 41
Fax: 02-66 75 42 99
Scandinavia Office
Taeby, Sweden
Tel: 08-63 80 820
Fax: 08-63 80 388
NEC Electronics (France) S.A.
NEC Electronics (Germany) GmbH
Duesseldorf, Germany
Tel: 0211-65 03 02
Fax: 0211-65 03 490
NEC Electronics (UK) Ltd.
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.2
4
User’s Manual U13130EJ4V0UM
Major Revisions in This Edition
Page
Description
p. 12
Addition of µPD77113A and deletion of µPD77118, 77116 to/from 1.3.2 (1) Target DSP
p. 13
Change of description in 1.3.4 Directory structure
The mark
shows major revised points.
User’s Manual U13130EJ4V0UM
5
PREFACE
Target Readers
This manual is intended for users who understand the functions of the µPD77016
Family and who will design application programs using this family of microcontrollers.
The µPD7701X Family is the generic name for the µPD7701X Family (µPD77015,
77016, 77017, 77018A, and 77019) and µPD77111 Family (µPD77110, 77111,
77112, 77113, 77113A, 77114, and 77115).
Purpose
The aim of this manual is to introduce readers to the basic functions of the µPD77016
Family by using application programs.
Note that programs and hardware
configurations shown in this document are for educational purposes only, and are not
intended for mass production.
Organization
This manual provides explanations of basic numerical operation programs.
CHAPTER 1 INTRODUCTION
CHAPTER 2 LIBRARY SPECIFICATIONS
CHAPTER 3 INSTALLATION
APPENDIX SAMPLE SOURCE (sample.asm)
How to Read This Manual
It is assumed that readers of this manual have general knowledge in the fields of logic
circuits and microcontrollers.
To learn about the hardware functions of the µPD7701X Family,
→ Read µPD7701X Family Architecture User’s Manual.
To learn about the hardware functions of the µPD77111 Family,
→ Read µPD77111 Family Architecture User’s Manual.
To learn about the instruction functions of the µPD77016 Family,
→ Read µPD77016 Family Instruction User’s Manual.
Conventions
Data significance:
Higher digits on the left and lower digits on the right
Active low:
××× (overscore over pin or signal name)
Note:
Footnote for item marked with Note in the text
Caution:
Information requiring particular attention
Remark:
Supplementary information
Number representation:
Binary ×××× or 0b××××
Decimal ××××
Hexadecimal 0x××××
6
User’s Manual U13130EJ4V0UM
Related Documents
The related documents indicated in this publication may include preliminary versions.
However, preliminary versions are not marked as such.
Documents Related to µPD77016 Family
Document Name
Pamphlet
Data Sheet
Part Number
µPD77016
U12395E
µPD77015
User’s Manual
Application Note
Architecture
Instructions
Basic Software
U10503E
U13116E
U11958E
U10891E
U10902E
µPD77017
µPD77018
µPD77018A
U11849E
µPD77019
µPD77019-013
U13053E
µPD77110
U12801E
U14623E
µPD77111
µPD77112
µPD77113A
U14373E
µPD77114
µPD77115
U14867E
Documents Related to Development Tools
Document Name
RX77016 User’s Manual
RX77016 Application Note
Caution
Document No.
Function
U14397E
Configuration Tool
U14404E
HOST API
U14371E
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 U13130EJ4V0UM
7
CONTENTS
CHAPTER 1 INTRODUCTION................................................................................................................. 11
1.1 Middleware.................................................................................................................................. 11
1.2 Echo Canceller ........................................................................................................................... 11
1.3 Product Overview....................................................................................................................... 12
1.3.1
Features ...................................................................................................................................... 12
1.3.2
Operating environment ................................................................................................................ 12
1.3.3
Performance ................................................................................................................................ 13
1.3.4
Directory structure ....................................................................................................................... 13
CHAPTER 2 LIBRARY SPECIFICATIONS ............................................................................................ 14
2.1 Echo Cancellation Processing Flow ........................................................................................ 14
2.2 Function Specifications............................................................................................................. 15
2.3
2.4
2.2.1
Memory structure......................................................................................................................... 15
2.2.2
Macro .......................................................................................................................................... 16
2.2.3
aec_Initialize function .................................................................................................................. 17
2.2.4
aec_EchoCancel function ............................................................................................................ 18
2.2.5
aec_GetVersion function ............................................................................................................. 19
Characteristics ........................................................................................................................... 20
Cautions ...................................................................................................................................... 21
CHAPTER 3 INSTALLATION .................................................................................................................. 22
3.1 Installation Procedure................................................................................................................ 22
3.2 Sample Creation Procedure ...................................................................................................... 22
3.3 Change of Location.................................................................................................................... 24
3.4 Symbol Naming Regulations .................................................................................................... 24
APPENDIX SAMPLE SOURCE (sample.asm)...................................................................................... 25
8
User’s Manual U13130EJ4V0UM
LIST OF FIGURES
Figure No.
Title
Page
1-1
Concept of Echo Canceller ............................................................................................................................ 11
2-1
Application Process ....................................................................................................................................... 14
2-2
Characteristics Measuring Configuration Diagram ........................................................................................ 20
3-1
Sample Program Evaluation System ............................................................................................................. 23
User’s Manual U13130EJ4V0UM
9
LIST OF TABLES
Table No.
Title
Page
1-1
Performance of µSAP77016-B01...................................................................................................................13
2-1
Symbol Name and Memory Size When Using AEC_CreateBuffer Macro......................................................16
2-2
Measuring Conditions of Characteristics........................................................................................................20
3-1
Section Names ..............................................................................................................................................24
3-2
Symbol Names...............................................................................................................................................24
10
User’s Manual U13130EJ4V0UM
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 voice codec and image data compression/decompression-type middleware, NEC is
offering users the kind of technology essential in the realization of a multimedia system for the µPD77016 Family, and
is continuing its promotion of system development.
The product introduced here is middleware that supplies the functions of an acoustic echo canceller.
1.2 Echo Canceller
The echo canceller contains functions to calculate the acoustic echo generated during hands-free telephoning (the
echo generated by the environment in which the hands-free telephone system is being used), and eliminate just the
echo element from the voice signal (which is made up of echo + voice + noise) on the receiving side.
The applications where the echo canceller is thought to be most effective include hands-free systems such as incar telephoning and video conferencing.
Figure 1-1. Concept of Echo Canceller
<Receiving side>
<Sending side>
Echo canceller
Hello
Adaptive
filter
Echo
Reference input
signal
Output signal
Noise
User’s Manual U13130EJ4V0UM
11
CHAPTER 1 INTRODUCTION
1.3 Product Overview
1.3.1 Features
• Employment of strong echo cancel algorithms for noise level fluctuation using an NEC original technique
• All voice I/O data (reference input signal, echo, output signal) is 16-bit linear data
• Full-duplex system echo canceller
• Appropriate-learning-type environment adaptability
• Echo elimination time freely settable
• Supports Windows™ based workbench for µPD77016 starter kit (WB77016 Ver2.21)
1.3.2 Operating environment
(1) Target DSP
µPD77015, 77016, 77017, 77018A, 77019, 77110, 77111, 77112, 77113, 77113A, 77114, 77115
(2) Required memory size
Usage
Size (words)
Instruction ROM
X Data RAM
Y Data RAM
Total
249
–
–
249
Coefficient table buffer
–
1 [word/tap]
1 [word/tap]
2 [word/tap]
Delay buffer
–
1 [word/tap]
–
1 [word/tap]
Work memory
–
–
19
19
Program code
Remarks 1. In addition, YRAM or YROM requires 24 words to store a copy write.
2. The memory size of the coefficient table buffer and delay buffer indicates size per tap.
Example:
When the number of taps is 512
Coefficient table size:
1[word/tap] × 512 taps × 2 = 1024 [words]
Delay buffer size:
1[word/tap] × 512 taps = 512 [words]
(3) Supported A/D, D/A specs
A/D 2 channels
D/A 1 channel
16-bit resolution
(4) Software tools
DSP tools: WB77016 Ver2.21 (Windows based)
WB77016 for µPD77016 Starter Kit Ver2.21sk (Windows based)
12
User’s Manual U13130EJ4V0UM
CHAPTER 1 INTRODUCTION
1.3.3 Performance
The performance of the µSAP77016-B01 is shown below.
Table 1-1. Performance of µSAP77016-B01
Operating Environment
DSP: µPD77016 (operation frequency: 33 MHz)
Number of taps: 512
Sampling frequency fs = 8 kHz
• When used in a real-world setting (for example, in a car)
Performance
Echo cancel processing time = about 68.88 [µs]
Number of taps × 4 [cycles] × (number of memory waits + 1) + (170 to 259) [cycles]
Echo elimination amount 30 [dB] (TYP.)
Echo elimination time 64 [ms]
1.3.4 Directory structure
The contents of the packages are shown below.
\
lib
aec016.lib: Library for µPD77016, 77110, and 77115 (For RAM)
aec01x.lib: Library for µPD77016 Family except above (For ROM)
smp
aec
sample.prj:
Project file
upd7701x.mac: Macro file
upd7701x.h:
Header file
userown.h:
User definition file
aec_lib.h:
Library header file
sample.asm:
Sample source
User’s Manual U13130EJ4V0UM
13
CHAPTER 2 LIBRARY SPECIFICATIONS
2.1 Echo Cancellation Processing Flow
The processing flow when the reference signals and the echo signal are input to the µPD77016 Family serial
interfaces (SIO1, SIO2) is shown below.
Figure 2-1. Application Process
Start
Echo canceller initialization
call aec_Initialize
Voice data input/output
processing interrupt handler
Voice input/output initialization
processing
• Reset AD/DA
• Interrupt enable, etc.
Echo/reference data input
processing
Echo cancellation processing
call aec_EchoCancel
No
Echo elimination data output
processing
Process ends?
Yes
Voice input/output completion
processing
• AD/DA completion setting
• Interrupt disable, etc.
End
14
User’s Manual U13130EJ4V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.2 Function Specifications
2.2.1 Memory structure
The following is an explanation of the structure of the memory required by this library.
• Coefficient table buffer
The area to which the learned coefficients are saved. Each coefficient is 32 bits long, and the higher and lower
16 bits are divided and saved to the X and Y memory areas, respectively. The size of the coefficient table
depends on the number of taps.
Example _ _ AEC_WORK_X XRAMSEG
ch1_al_buff: ds tapnum ; 32bit coefficient of low word
_ _ AEC_WORK_Y YRAMSEG
ch1_ah_buff: ds tapnum ; 32bit coefficient of high word
• Delay buffer
The area to which the reference signals input to the echo canceller are saved. Secure X memory space for the
delay buffer and align the first address of the secured area with the number of taps
Note
. The size of the delay
buffer depends on the number of taps.
Note When the number of taps is 2 (512, 256, 128, …) → Align with 2
n
n
When the number of taps is 2 +α (500, 300, 200, etc.) → Align with 2
n
n+1
Example _ _ AEC_WORK_X XRAMSEG align at tapnum
ch1_z_buff: ds tapnum ; z buffer
• Work memory
The area to which the statuses of the echo canceller are saved. Secure 19 words of the Y memory space for
the work memory.
Example _ _ AEC_WORK_Y YRAMSEG
ch1: ds 19 ; work memory
Cautions 1. Take care to avoid destroying the coefficient table buffer, delay buffer, and work memory
areas while operating the echo canceller after calling the aec_initialize function. Normal
operation of this library cannot be guaranteed if these areas are destroyed.
2. Neither of the coefficient table areas (higher 16 bits, lower 16 bits) can be allocated to
external memory.
User’s Manual U13130EJ4V0UM
15
CHAPTER 2 LIBRARY SPECIFICATIONS
2.2.2 Macro
The macro used by this library is defined by aec_lib.h. To use this macro, aec_lib.h must be Included.
• AEC_CreateBuffer macro
The AEC_CreateBuffer macro secures and declares the 1 channel of memory area required for echo
cancellation processing. Accordingly, when configuring multiple channels, declare this macro for the required
number of channels only.
[Classification]
Securing memory
[Function name]
AEC_CreateBuffer
[Summary of function]
Secures 1 channel of memory area.
[Format]
%AEC_CreateBuffer(name,tapnum)
Type
Argument
WORD
name
WORD
tapnum
[Arguments]
Description
Symbol name
Number of taps
[Return value]
None
[Function]
Allocates the delay buffer, coefficient table, and work memory from the memory.
Example
When the AEC_CreateBuffer macro is declared with a setting whereby the symbol name = ch1 and the
tap number is 256:
%AEC_CreateBuffer(ch1, 256)
The symbol names and memory sizes when the AEC_CreateBuffer macro is used are as follows.
Table 2-1. Symbol Name and Memory Size When Using AEC_CreateBuffer Macro
Symbol Name
16
Size[words]
X/Y
Description
ch1_z_buff
256
X
Delay buffer area
ch1_al_buff
256
X
Coefficient table area (lower 16 bits)
ch1_ah_buff
256
Y
Coefficient table area (higher 16 bits)
ch1
19
Y
Work memory first address
User’s Manual U13130EJ4V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.2.3 aec_Initialize function
The aec_Initialize function initializes the coefficient settings, coefficient table, and delay buffer. The aec_Initialize
function performs initialization processing on 1 channel. To initialize multiple channels, call the aec_Initialize function
for each channel individually.
[Classification]
Echo canceller initialization processing
[Function name]
aec_Initialize
[Summary of function]
Initializes the RAM area used for the echo canceller and sets parameters.
[Format]
call aec_Initialize
[Arguments]
Type
Argument
Description
register
R0L
Number of taps (elimination time × sampling frequency)
register
R1L
Step size (learning amount)
register
R2L
α coefficient (0 to 8)
register
R3L
β coefficient (0.99 to 0.999)
register
DP0
Coefficient table first address (low word)
register
DP1
Delay buffer first address
register
DP4
Coefficient table first address (high word)
register
DP5
Work memory first address
[Return value]
None
[Function]
Initializes this library, makes parameter settings, etc.
[Registers used]
R0, R1, R2, R3, DP0, DP1, DP4, DP5
[Loop stack levels]
1 level used
[Stack levels]
0 levels used
Caution The echo canceller may not be able to perform normal processing if values outside the
allowable range are set for the α and β coefficients.
Remark
If the voice after processing is distorted due to excessive noise, either make the step size smaller, or
the α coefficient larger. If convergence is slow, either make the step size larger, or the α coefficient
smaller. If the variation in the power of the noise is extreme, make the β coefficient smaller (but within
the range of 0.990 to 0.999). The recommended values for the step size, and α and β coefficients are
as follows.
Step size = 0.1
α coefficient = 5
β coefficient = 0.995
User’s Manual U13130EJ4V0UM
17
CHAPTER 2 LIBRARY SPECIFICATIONS
2.2.4 aec_EchoCancel function
The aec_EchoCancel function creates an echo-free signal by eliminating the echo from the echo and reference
signals.
[Classification]
Echo cancellation processing section
[Function name]
aec_EchoCancel
[Summary of function]
Performs echo cancellation processing on signals that include echo.
[Format]
call aec_EchoCancel
[Arguments]
[Return value]
[Function]
Type
Argument
Description
register
R0H
Echo signal (16-bit linear PCM)
register
R1H
Reference signal (16-bit linear PCM)
register
DP0
Coefficient table first address (low word)
register
DP1
Delay buffer first address
register
DP4
Coefficient table first address (high word)
register
DP5
Work memory address
Type
Argument
register
R0H
Description
Signal after eliminating echo (16-bit linear PCM)
Creates a signal from which the echo has been eliminated by creating a replica echo
from the reference signal and removing the replica echo signal from the echo signal.
18
[Registers used]
R0, R1, R2, R3, R4, R5, DP0, DP1, DP4, DP5, DN1, DMX
[Loop stack levels]
1 level used
[Stack levels]
0 levels used
User’s Manual U13130EJ4V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.2.5 aec_GetVersion function
The aec_GetVersion function returns the version information of this library.
[Classification]
Echo canceller version information acquisition function
[Function name]
aec_GetVersion
[Summary of function]
Returns the version information.
[Format]
call aec_GetVersion
[Arguments]
None
[Return Value]
[Function]
Type
Return value
Description
register
R0H
Major version number
register
R0L
Minor version number
Returns the version number of this library as a 32-bit value.
Example When R0 = 0x00’0x0001’0x0100:
Version: V1.01
[Registers used]
R0
[Loop stack levels]
0 levels used
[Stack levels]
0 levels used
User’s Manual U13130EJ4V0UM
19
CHAPTER 2 LIBRARY SPECIFICATIONS
2.3 Characteristics
The characteristics of the amount of echo eliminated (ERLE) from this library’s reference signal and echo signal
levels are shown below.
50
40
40
ERLE [dB]
50
30
20
Echo Signal Level vs. ERLE
Characteristics
30
20
10
10
0
0
0
-10
-20
-30
-40
0
-50
-10
-20
-30
-40
-50
Echo signal level [dB]
Table 2-2. Measuring Conditions of Characteristics
Reference Signal Level vs ERLE
Reference signal
Echo Signal Level vs ERLE
4-kHz band white noise
The average power of white noise is 5.87 × 107 (average value: 7660) with a 16-bit quantized
value (–32768 to 32767).
Delay time [ms]
2
ATT1 [dB]
0 to –50
0
ATT2 [dB]
0
0 to –50
Figure 2-2. Characteristics Measuring Configuration Diagram
4-kHz band white noise
µSAP77016-B01
ATT1
Reference signal
Echo elimination
signal
Echo signal
20
User’s Manual U13130EJ4V0UM
Delay device
ATT2
CHAPTER 2 LIBRARY SPECIFICATIONS
2.4 Cautions
• Set the return amount of the echo included in the echo signal so that it attenuates. If the return amount is
amplified, it will be impossible to eliminate the echo.
• Set the level of the reference signal so that it does not overflow at CODEC.
• Do not input a tone signal (DTMF signal etc.) for the reference signal. If a tone signal is input, the amount of
echo cancelled will be reduced.
• If the variation of the echo path
Note
is extreme, the echo canceller will have trouble converging the learning of
the echo path.
• If the echo canceller is used in a noisy environment, converging the learning of the echo path may take longer
than when the echo canceller is used in a noise-free environment.
Note Echo path: The path along which the voice is reflected and returns.
User’s Manual U13130EJ4V0UM
21
CHAPTER 3 INSTALLATION
3.1 Installation Procedure
The µSAP77016-B01 is supplied on a 3.5-inch floppy disk (1.44 MB). The procedure for installing the µSAP77016B01 in the host machine is outlined below.
(1) Set the floppy disk in the floppy disk drive and copy the files to the directory where software tools are used
(e.g. C:\DSPTools). The following is an example of when files are copied from the A drive to the C drive.
a:\>xcopy /s *.* c:\DSPTools <CR>
(2) Confirm that the files have been copied. Refer to 1.3.4 Directory structure for details on the directories.
a:\>dir c:\DSPTools <CR>
3.2 Sample Creation Procedure
The sample program is stored in the smp directory. Refer to APPENDIX SAMPLE SOURCE (sample.asm) for
details on the sample.asm source program.
With the sample program is it possible to connect a microphone, speakers, etc. and evaluate a hands-free system.
Note that the sample program operates with the µPD77016 starter kit.
22
User’s Manual U13130EJ4V0UM
CHAPTER 3 INSTALLATION
Figure 3-1. Sample Program Evaluation System
Mobile terminal
Speaker
R channel
µPD77016 starter kit
L channel
LINE output
DSP
R channel
LINE input
CODEC
Microphone
L channel
The following is an explanation of how to build the µSAP77016-B01 sample program.
(1) Start up the WB77016.
(2) Open the sample.prj project file.
Example Specify C:\DSPTools\smp\aec\sample.prj with the Open Project command on the Project menu.
(3) Execute Build and confirm that sample.lnk has been created.
Example The sample.lnk file can be created by selecting the Build All command from the Make menu.
(4) Execute the sample program by downloading it to the target system using the starter kit debugger
(ie77016s.exe).
Cautions 1. Use the starter kit workbench to create the sample file.
2. Because the file structure of the project file (sample.prj) is specified via an absolute path, if
the library has been installed in a directory other than “C:\DSPTools”, it is necessary to
reset the file structure.
User’s Manual U13130EJ4V0UM
23
CHAPTER 3 INSTALLATION
3.3 Change of Location
The section names shown in Table 3-1 below have been attached in this library. The locations can be changed to
accord with the user’s target system.
Table 3-1. Section Names
Section Name
Type
Description
_ _ AEC_WORK_X
XRAMSEG
X memory area data RAM
_ _ AEC_WORK_Y
YRAMSEG
Y memory area data RAM
_ _ AEC_COPYRIGHT_Y
YROMSEG/YRAMSEG
Copyright storage area
_ _ AEC_LIB
IROMSEG/IRAMSEG
Echo canceller program
3.4 Symbol Naming Regulations
The symbols used in this library are named according to the following regulations. Take care not to duplicate these
names when using the µSAP77016-B01 in combination with another application.
Table 3-2. Symbol Names
Classification
24
Regulation
Function
aec_XXXX
Macro, constant
AECXXXX
User’s Manual U13130EJ4V0UM
APPENDIX SAMPLE SOURCE (sample.asm)
/*----------------------------------------------------------------------*/
/*
File Information
*/
/*----------------------------------------------------------------------*/
/*
Name
: sample.asm
*/
/*
Type
: Assembler program module
*/
/*
Version
: 1.00a
*/
/*
Date
: 1997 JAN 14
*/
/*
CPU
: uPD7701x Family
*/
/*
Assembler
: WB77016
*/
/*
About
:NEC uPD7701x Family Middle-Ware
*/
/*
Sample Program of Echo Canceller Library
*/
/*----------------------------------------------------------------------*/
/*
Copyright (C) NEC Corporation 1996
*/
/*
NEC CONFIDENTIAL AND PROPRIETARY
*/
/*
All rights reserved by NEC Corporation.
*/
/*
Use of copyright notice does not evidence publication
*/
/*----------------------------------------------------------------------*/
#include "aec_lib.h"
#include "userown.h"
#include "upd7701x.mac"
/* =========================================================================
*
Define CODEC(uPD63310) control register
* ====================================================================== */
#define CODEC_CTL
*0x4000:X
#define CGAIN_ADR
*0x8000:X
#define CGAIN_DAT
*0x8001:X
/* =========================================================================
*
Define echo canceller status
* ====================================================================== */
#define TAPS 512
#define U0
0.1
#define ALFA 5
#define BETA 0.995
/* =========================================================================
*
Allocate echo canceller buffer
* ====================================================================== */
%AEC_CreateBuffer(ch1, TAPS);
/* =========================================================================
*
Allocate work buffer
* ====================================================================== */
WORK_Y YRAMSEG
R0TMP: ds
3
cnt:
ds
1
flag: ds
1
echo: ds
1
ref:
ds
1
err:
ds
1
#define CNT
#define FLAG
*cnt:Y
*flag:Y
User’s Manual U13130EJ4V0UM
25
APPENDIX SAMPLE SOURCE (sample.asm)
#define ECHO
#define REF
#define ERR
*echo:Y
*ref:Y
*err:Y
/* =========================================================================
*
Vector registration
* ====================================================================== */
%BeginVector(StartUp)
;Regist start up routine
%NotUseVector(VectorINT1)
;
%NotUseVector(VectorINT2)
;
%NotUseVector(VectorINT3)
;
%NotUseVector(VectorINT4)
;
%RegistVector(VectorSI1, SI1Handler)
;Regist SI1 handler
%NotUseVector(VectorSO1)
;
%NotUseVector(VectorSI2)
;
%NotUseVector(VectorSO2)
;
%NotUseVector(VectorHI)
;
%NotUseVector(VectorHO)
;
%EndVector
/* =========================================================================
*
Sample programe code section
* ====================================================================== */
SAMPLE_CODE
IMSEG at 0x240
StartUp:
;;=================================================================;;
;;
Initialize Register & Peripheral Units
;;
;;=================================================================;;
%ClearAllRegister
;Clear all uPD7701x register
%SetIWTR(0x0054)
;Set instruction ROM/RAM wait cycle
%SetDWTR(0x3c3c)
;Set data ROM/RAM wait cycle
%SetPort(P0_OUT_MODE|P0_L_LEVEL) ;Set P0 output mode & low level
%SetPort(P1_OUT_MODE|P1_L_LEVEL) ;Set P1 output mode & low level
%SetPort(P2_IN_MODE)
;Set P2 output mode & low level
%SetPort(P3_IN_MODE)
;Set P3 input mode
;;=================================================================;;
;;
Initialize CODEC chip(uPD63310)
;;
;;=================================================================;;
clr(R0)
;
clr(R1)
;
R1L = 0x0002
;
CGAIN_ADR = R0L
;ch1-L
nop
;
CGAIN_DAT = R1L
;
R0L = 0x0001
;ch1-R
CGAIN_ADR = R0L
;
nop
;
CGAIN_DAT = R1L
;
R0L = 17
;out-L
CGAIN_ADR = R0L
;
R0L = 0x0001
;
CGAIN_DAT = R0L
;
R0L = 18
;out-R
CGAIN_ADR = R0L
;
R0L = 0x0001
;
CGAIN_DAT = R0L
;
R0L = 0x000f
;
CODEC_CTL = R0L
;
26
User’s Manual U13130EJ4V0UM
APPENDIX SAMPLE SOURCE (sample.asm)
;;==============================================================;;
;;
Initialize Echo cannceller module
;;
;;==============================================================;;
R0L = TAPS
;Initialize echo cancel module
R1L = U0
;
R2L = ALFA
;
R3L = BETA
;
DP0 = ch1_al_buff
;
DP4 = ch1_ah_buff
;
DP1 = ch1_z_buff
;
DP5 = ch1
;
call aec_Initialize
;
;;==============================================================;;
;;
Initialize work/flag memory
;;
;;==============================================================;;
clr(R0)
;
CNT = R0L
;
FLAG = R0L
;
ECHO = R0L
;
REF = R0L
;
;;==============================================================;;
;;
Initialize Serial I/F
;;
;;==============================================================;;
R0L = 0x0200
;Initialize Serial I/F 1
*SST1:X = R0L
;
%DisableMask(SR_ALL)
;Disable all interrupt mask
%EnableMask(SR_SI1)
;Enable SI1 interrupt mask
%EnableInterrupt
;Enable interrupt
;;==============================================================;;
;;
Main routine
;;
;;==============================================================;;
loop1:
nop
R0 = FLAG
if(R0 == 0) jmp loop1
R0 = ECHO
R1 = REF
DP0 = ch1_al_buff
DP4 = ch1_ah_buff
DP5 = ch1
call aec_EchoCancel
ERR = R0H
clr(R0)
FLAG = R0H
jmp loop1
;Wait Echo canceller start flag
;
;
;Set echo signal to R0
;Set reference signal to R1
;Set coefficient table start address
;
;Set AECINFO struck start address
;Echo cancel process
;Get echo removabled signal
;
;
;
;;==============================================================;;
;;
SI1 handler
;;
;;==============================================================;;
SI1Handler:
*R0TMP+0:Y = R0L
;Save work register of R0
*R0TMP+1:Y = R0H
;
*R0TMP+2:Y = R0E
;
R0L = *PDT:X
;if P3 is low level, no echo canceller.
R0 = R0 & 0x0008
;
if(R0 == 0) jmp no_cancel ;
User’s Manual U13130EJ4V0UM
27
APPENDIX SAMPLE SOURCE (sample.asm)
clr(R0)
R0L = CNT
R0 = R0 ^ 0x0001
CNT = R0L
if(R0 == 0) jmp R_channel
L_channel:
R0 = *SDT1:X
ECHO = R0H
R0 = ERR
jmp si1_end
R_channel:
R0 = FLAG
if(R0 == 0) jmp no_error
%SetPort(P0_H_LEVEL)
no_error:
R0 = *SDT1:X
REF = R0H
R0L = *PDT:X
R0 = R0 & 0x0004
if(R0 != 0) jmp $+3
R0H = ERR
jmp $+2
R0H = REF
R0L = 0x0001
FLAG = R0L
si1_end:
*SDT1:X = R0H
R0E = *R0TMP+2:Y
R0H = *R0TMP+1:Y
R0L = *R0TMP+0:Y
reti
;Echo cancel process
;
;
;
;
no_cancel:
clr(R0)
R0L = CNT
R0 = R0 ^ 0x0001
CNT = R0L
if(R0 == 0) jmp R_channel2
R0 = *SDT1:X
ECHO = R0H
jmp si1_end
R_channel2:
R0 = *SDT1:X
REF = R0H
R0H = ECHO
jmp si1_end
;No cancel process
;
;
;
;
;
;Get L-channel signal
;
;
;Get L-channel signal
;Save echo signal
;Load output signal
;
;
;
;
;Get R-channel signal
;Save reference signal
;
;
;
;
;
;
;Set echo canceller start flag
;
;Output signal
;Save work register of R0
;
;
;
;Get R-channel signal
;
;
;
end
28
User’s Manual U13130EJ4V0UM
[MEMO]
User’s Manual U13130EJ4V0UM
29
[MEMO]
30
User’s Manual U13130EJ4V0UM
Facsimile Message
From:
Name
Company
Tel.
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.
FAX
Address
Thank you for your kind support.
North America
Hong Kong, Philippines, Oceania
NEC Electronics Inc.
NEC Electronics Hong Kong Ltd.
Corporate Communications Dept. Fax: +852-2886-9022/9044
Fax: +1-800-729-9288
+1-408-588-6130
Korea
Europe
NEC Electronics Hong Kong Ltd.
NEC Electronics (Europe) GmbH
Seoul Branch
Technical Documentation Dept.
Fax: +82-2-528-4411
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
Taiwan
NEC Electronics Taiwan Ltd.
Fax: +886-2-2719-5951
I would like to report the following error/make the following suggestion:
Document title:
Document number:
Page number:
If possible, please fax the referenced page or drawing.
Document Rating
Excellent
Good
Acceptable
Poor
Clarity
Technical Accuracy
Organization
CS 01.2