Download: AVR336: ADPCM Decoder

AVR336: ADPCM Decoder Features • AVR Application Decodes ADPCM Signal in Real-Time • Supports Bit Rates of 16, 24, 32 and 40 kbit/s • More Than One Minute Playback Time on ATmega128 (at 16 kbit/s) • Decoded Signal Played Using Timer/Counter in PWM Mode 1 Introduction Adaptive Differential Pulse Code Modulation, or ADPCM, is a digital compression technique used mainly for speech compression in telecommunications. ADPCM is a waveform codec that can also be used to code other signals than speech, such as music or sound effects. ADPCM is simpler than advanced low bit-rate voice coding techniques a...
Author: Zoble1980 Shared: 8/19/19
Downloads: 120 Views: 1156

Content

AVR336: ADPCM Decoder Features

• AVR Application Decodes ADPCM Signal in Real-Time • Supports Bit Rates of 16, 24, 32 and 40 kbit/s • More Than One Minute Playback Time on ATmega128 (at 16 kbit/s) • Decoded Signal Played Using Timer/Counter in PWM Mode 1 Introduction Adaptive Differential Pulse Code Modulation, or ADPCM, is a digital compression technique used mainly for speech compression in telecommunications. ADPCM is a waveform codec that can also be used to code other signals than speech, such as music or sound effects. ADPCM is simpler than advanced low bit-rate voice coding techniques and doesn’t require as heavy calculations, which means encoding and decoding can be done in a relatively short time. ADPCM is usually used to compress an 8 kHz, 8-bit signal, with an inherent flow rate of 64 Kbit/s. When encoded at the highest compression ratio, using only 2 bits to code the ADPCM signal, the flow rate is reduced to 16 Kbit/s, i.e. 25% of the original. Using 4-bit coding, the flow rate is 32 Kbit/s, i.e. 50% of the original, and the quality of the signal is fine for most applications. This application note focuses on decoding the ADPCM signal. It uses the on-chip timer/counter to create a Pulse-Width Modulated (PWM) output signal, which is then passed through a simple, external filter. The filter consists of just a few external components and turns the digital signal into analog, suitable for connecting to speakers. For further information about D/A conversion with Timer/Counter, please refer to Application Note AVR335: Digital Sound Recorder with AVR® and DataFlash®. Figure 1-1. ADPCM Decoding on an AVR Microcontroller Output Input ADPCM ADPCM Encoder DecoderCompressed Data on an AVR 8-bit

Microcontrollers Application Note

Rev. 2572A-AVR-11/04, 2 Theory of Operation The principle of ADPCM is to predict the current signal value from previous values and to transmit only the difference between the real and the predicted value. In plain Pulse-Code Modulation (PCM) the real or actual signal value would be transmitted. In ADPCM the difference between the predicted signal value and the actual signal value is usually quite small, which means it can be represented using fewer bits than the corresponding PCM value. Depending on the desired quality and compression ratio, a difference signal is quantized using 4, 8, 16 or 32 levels. The block diagram of an ADPCM encoder is shown in Figure 2-1. For more information on how the encoder works see Reference 2. Figure 2-1. Block Diagram of ADPCM Encoder I ( k ) Output signal sl ( k ) Difference d (k) I(k) Inversedq( k ) Reconstructed Input signal Adaptive quantizer Adaptive signal calculator quantizer calculator signal se ( k ) y(k ) sr (k) y(k) se (k) y(k ) Adaptive predictor Quantizer Adaption Scale factor speed adaption control a1 (k ) t r ( k ) a2 (k) td (k) y (k) Tone and l transition detector The decoder shown in Figure 2-2 takes the quantized value, performs an inverse quantization, and subtracts the result from the predicted signal to get the decoded signal. The decoder is described in more details below. Headings refer to block names in Figure 2-2. For exact formulas, see “Appendix B: Formulas”. 2 AVR336,

AVR336

Figure 2-2. Block Diagram of ADPCM Decoder. I ( k ) Inverse dq (k) Reconstructed Input ADPCM adaptive signal quantizer calculator Signal sr ( k ) y(k ) se (k) Reconstructed Output Signal y(k) Adaptive predictor Quatizer Adaptation Scale factor Speed adaptation control a1 (k) tr (k) a 2 ( k ) td (k) y ( k ) Tone and l transition detector 2.1 Inverse Adaptive Quantizer d (k) = 2dq ln (k )+ y(k )q This block calculates the linear quantized difference signal dq(k) from the logarithmic quantized difference signal dq ln(k ) and the adaptation factor y(k) . The logarithmic quantized difference signal dq ln(k ) is obtained from a static look-up table using the ADPCM codeword I (k) as index. The linear domain difference signal is calculated by raising 2 to dq ln(k ) + y(k) . 2.2 Quantizer Scale Factor Adaptation The scale factor y(k) used in the inverse adaptive quantizer is computed here. The scale factor y(k) consists of two other factors; the fast (unlocked) scale factor yu (k) and the slow (locked) scale factor yl (k) . Two scale factors are needed to handle different types of signals; a fast scale factor allows adaptation to signals with large fluctuations (e.g. speech), while a slow scale factor is needed when the signal changes slowly (e.g. tone signals). The scale factor is a linear combination of these two. The ratio is determined by speed control parameter al , described in the next section. 2.3 Adaptation Speed Control The adaptation speed is controlled by the parameter al . It approaches unity with speech signals and zero with audio band data signals. To obtain al two measures of average magnitude (long- and short-term) of ADPCM codeword I (k ) are calculated. The difference between these two indicates how the average magnitude of I (k ) is changing. If the difference is small, the magnitude of I (k ) is constant; if the difference is large, the magnitude of I (k ) is changing, as indicated by the speed control parameterap. The parameter also takes into account the special cases where transitions are detected, or when the signal is idle. Finally, the limited speed control parameter al , is obtained fromap(ranging from zero to two) by limiting it to range between zero and one. This is done asymmetrically to delay the transition from fast to slow adaptation mode., 2.4 Tone and Transition Detector Tone and transition detections are included to improve the codec’s response when handling data signals instead of speech. If the signal uses only a narrow frequency band (e.g. tone signals), the quantizer is set to fast adaptation mode. If transitions are detected, the quantizer is set to fast adaptation mode (tr =1) and the coefficients of the adaptive predictor are set to zero. 2.5 Adaptive Predictor se (k) = sep + sez The adaptive predictor calculates the signal estimate se (k) from the quantized difference signal dq (k) . It uses two adaptive structures; a second-order structure that models the poles ( sep ), and a sixth-order structure that models the zeroes ( sez ). The coefficients in both structures are updated with a simplified gradient algorithm. In order to ensure stability the coefficients in the pole-modeling structure must be limited. The formulas for updating the coefficients in the zero-modeling structure are slightly different for different bit rates (5-bit vs. 2-, 3-, or 4-bit). If a transition is detected, all predictor coefficients in both structures are set to zero (see previous block). 2.6 Reconstructed Signal Calculator sr (k ) = se (k ) + dq (k ) The reconstructed signal sr (k) is calculated by simply adding the signal estimate se (k) to the difference signal dq (k) . 3 Implementation This section describes the software implementation of the decoder. 3.1 Software The decoder is implemented using IAR Systems C compiler, with some sections written in assembler. The main structure of the decoder shown in Figure 3-1 is simple; the program waits for a user to push a button, and then starts to decode pre-encoded samples from the Flash memory. It first calls get_code() which reads the data from the Flash and extracts the ADPCM codeword from it (one byte contains several codewords). 4 AVR336,

AVR336

Figure 3-1. Flow chart of Main Program. Start init_PWM() init_ADPCM()

NO

Button pressed?

YES

get_code()

NO

YES NO Output YES End of Decoded Sample decode() buffer ready forrecording? to output buffer write? Next, the decode() –function is called, as shown in Figure 3-2. The function calculates the signal estimate (see predictor() ), the quantizer scale factor y, and the difference signal dq. Possible transition signals are detected, and scale factor step size parameters and adaptive predictor coefficients are updated. Finally, the decoder detects possible tone signals and updates adaptation speed control parameters. Figure 3-2. Flow chart of Decoder-Function. decode() predictor() Scale factor stepsize update Scale factor update_pred_coeff()adaptation Difference Signal Tone dq c alculation Detection Transition Speed Control detection param. update Return Decoded Signal sr The reconstructed signal sr is output through a simple D/A-converter, consisting of timer/counter1 in PWM mode (output to port B, pin 5) and an external filter., 3.1.1 Compliance with ITU-T G.726 The software follows quite closely what has been described above, but some changes have been made for more efficient computation. The ADPCM-standard ITU- T G.726 defines some calculations involving reconstructed signal sr (k) to be made with floating point arithmetic. These calculations are skipped in this implementation and are instead realized using fixed-point arithmetic. This has been done in order to save processor clock cycles. Using fixed point instead of floating point arithmetic could cause a small reduction in the quality of the reconstructed signal. Two blocks have been left out completely, namely the µ-law and A-law conversion and synchronous coding adjustments. µ-law and A-law conversion are used to reduce the number of bits per sample. Since the output directly drives a D/A-stage, there’s no need for µ-law/A-law -conversions. The synchronous coding adjustment defined in the G.726 standard has also been skipped in this implementation. The purpose of the synchronous coding adjustment is to prevent distortion in synchronous tandem codings (e.g. ADPCM-PCM-ADPCM), which is not used in this application. To achieve best possible quality, the encoding and decoding processes should use the same algorithms, i.e. the encoding should also be done with fixed-point arithmetic. 3.2 Hardware To run the software an ATmega128 processor is used. To achieve better quality, it is highly recommended to use an active low-pass filter between the PWM output and the loudspeaker/headphone/amplifier to filter out the PWM base frequency. The PWM output and a suggested filter circuit has been described in Application Note AVR335. The schematics for a simpler, second order active filter implemented with a single- sided low-voltage operational amplifier is shown in Appendix C. An STK500 development board with an STK501 expansion module is also recommended. When decoding signals with an 8 kHz sample rate the AVR must run at 16 MHz and an external oscillator is required in such cases. 4 Implementation Example This section gives step-by-step instructions on how to decode compressed ADPCM samples with an ATmega128 and the STK500/501 evaluation board. To decode an ADPCM signal with 8 kHz sample rate the system clock frequency needs to be 16 MHz. 4.1 Quick Start To use the ADPCM-decoder: • Copy one of the included encoded sound samples to the source directory and rename it to “data.c”. • Start IAR Embedded Workbench, open the workspace file and configure the workspace; Edit the BITS and INPUTSIZE parameters in “adpcm.h” according to selected sound sample file (“data.c”) and rebuild the project. • Download the compiled and linked program to the target AVR. • Build and connect the output filter between the PWM output (PB5 on Atmega128) and the loudspeaker. 6 AVR336,

AVR336

The signal is now ready to be decoded and played back. 4.2 ADPCM Sound Files Some encoded sound samples are included with this application note. Copy one of the files to the source directory and rename it to “data.c”. Alternatively, use third-party software to create new ADPCM sound files. If using custom ADPCM data please note that the binary data must be copied into an array, as shown in the included sample files. See Appendix E on how to encode ADPCM files. 4.3 Compile & Link To compile and link the source code in IAR Embedded Workbench: • Open workspace “AVR336.eww”. • Set output format to UBROF-8 (Project > Options > XLINK > Output > UBROF-8). IAR Embedded Workbench 3.10 generates UBROF 9 by default, but AVR Studio 4.10 currently supports UBROF 8, and previous. This may change as new releases are launched. • In the project window, double-click on the file “adpcm.h” to open it. Update the ADPCM settings in the file to match the format of the ADPCM sound file. INPUTSIZE defines the length of the sound record and BITS defines the number of bits used for encoding. • In the project window, left-click on the file “data.c” and select Compile from the pop-up menu. This is to make sure the compiler doesn’t use a precompiled version of an old sound file. • Compile and link the project (Project -> Make). 4.4 Hardware Set-Up Attach STK501 to STK500 and populate the top-module with an ATmega128. Connect push buttons to port D using a flat cable (connect the cable between SWITCHES and PORTD). Configure the target AVR to run at the desired frequency (default is using a 16 MHz external crystal). Connect the AVR and/or STK500 to a PC using direct cable connection or a choice of programmer/debugger. 4.5 Firmware Set-Up Start AVR Studio and open the file “adpcm.dbg” from the IAR output directory (“Debug/Exe” or “Release/Exe”). Configure AVR Studio for the debug platform and AVR in use. The program is now ready to run. 4.6 Filter Circuit The output filter circuit is not mandatory, but improves sound quality considerably. One possible filter circuit is described in application note AVR335. If using the circuit described in AVR335 please note that only the output part of the circuit is required; there is no need for the microphone pre-amplifier. Alternatively, a simpler filter circuit is shown in Appendix C., 5 Porting The program can be ported to other AVR devices quite easily. Things that may need to be changed include reference type for packed data memory and PWM output pin. For example, to use the decoder on an ATmega32, replace all “_hugeflash” with “_flash” in files “main.c”, “adpcm.c” and “data.c”. The PWM output, OC1A, of ATmega32 is located on pin PD5 instead of PB5. Hence, the function “initialize_pwm()“ in file “adpcm.c” must be changed accordingly. It is recommended to use an AVR with integrated multiplier. 6 Performance The amount of Flash memory required for a sound recording depends on the sample rate, the ADPCM bit rate, and of course, the length of the recording. The table below shows memory requirements for one second of sound at different bit rates and sample rates. Table 6-1. Flash Memory Required per One Second of Sound Data Sample rates (Hz) Bits/Sample 4000 6000 8000 2 1,00 kB 1,50 kB 2,00 kB 3 1,50 kB 2,25 kB 3,00 kB 4 2,00 kB 3,00 kB 4,00 kB 5 2,50 kB 3,75 kB 5,00 kB For example: a 10-second recording encoded with 4 bits and at a sample rate of 8 kHz requires 320 kilobits = 40 kilobytes (kB) of memory. This means that, for example, an ATmega128 running the ADPCM decoder (about 3kB) can play back up to (128-3) kB / (32/8) = more than 31 seconds of 8-kHz, 4-bit, ADPCM encoded data. 6.1 Clock Cycles The table below shows clock cycle requirements per one sample. The bit rate has only a minimal effect on clock cycle requirements (the average values in the table are from the 4-bit version). To find out the required clock frequency of the AVR, multiply the total number of clock cycles by the sample rate. Table 6-2. Average and Worst-Case Clock Cycle Requirements Function Average Worst-case Clock Cycles/Sample Clock Cycles/Sample get_code() 130 140 decode() 1600 1860 T/C3 ISR 60 70 Other 140 150 Decoder Loop Total 1930 2220 For example: the sound recording is sampled at 7812 Hz, and the average total clock cycle requirement is 1930. The AVR needs to operate at 1930 x 7812 Hz = 15 MHz, which rounds to 16 MHz with headroom. The worst-case clock cycle requirement 8 AVR336,

AVR336

does exceed 16 MHz and therefore a small buffer is needed to prevent audible distortions caused by calculations taking too long. The length of the buffer can be adjusted (see source code). A long buffer reduces the risk of a buffer underrun but requires more memory (two bytes per element). 6.2 Memory The memory requirements are listed in the table below. The source code includes the possibility to use all bit levels (2…5 bits), but in a typical application only one bit level is needed. Removing the support for other bit levels will reduce the program memory requirement. Table 6-3. Memory Requirements (Excluding Sound Data) Code Memory (bytes) Data Memory (bytes) < 3000 (+ sound data) < 40 (+ output buffer), 7 Appendix A: Tables This appendix shows tables needed in 4-bit ADPCM decoding. Corresponding values for other bit levels (2, 3, and 5) can be found directly from the source code (“adpcm.c”). In the source code some table values are represented using fixed-point decimal numbers. The number of bits reserved for the decimal part is indicated by Qn notation. For example, using Q4 notation the number 4.75 is written in binary as “0000 0000 0100.1100”. Table 7-1. Function W() and F() Values for 4-bit Coding |I(k)| W|I(k)| (Q4 notation) F|I(k)| (Q9 notation) 0 -0.75011.13022.56034.00147.001512.381622.193770.13 7 Table 7-2. Inverse Quantizing Table for 4-bit Coding |I(k)| |DQLN(k)| (Q7 notation) 0 -2048142135 3 213 4 273 5 323 6 373 7 425 10 AVR336,

AVR336

8 Appendix B: Formulas This appendix shows the mathematical formulas used in decoding the ADPCM signal. Headings refer to block names in Figure 2-2. 8.1 Inverse Adaptive Quantizer To convert from logarithmic domain to linear, the following formula is used: d (k) = 2dq ln (k )+ y(k )q 8.2 Quantizer Scale Factor Adaptation Locked and unlocked scale factors are combined with the formula y(k) = al (k)yu (k −1) + (1− al (k))yl (k −1) where 0 ≤ al (k) ≤ 1 The unlocked (fast) scale factor yu (k) (see tables in Appendix A for definitions of function W values for different bit rates): yu (k ) = (1− 2−5 )y(k )+ 2−5W I (k ) The locked (slow) scale factor yl (k) : yl (k ) = (1− 2−6 )yl (k −1)+ 2−6 yu (k) yu (k) is limited between 1.06 and 10.00. 8.3 Adaptation Speed Control The adaptation speed is controlled with parameter al . It approaches 1 with speech signals and 0 with audio band data signals. The parameter is calculated by limiting the speed control parameterap(k) to be less than or exactly 1: ⎧1, if a (k −1) >1 al (k) = p ⎨ ⎩a p (k −1), ifap(k −1) ≤1 Unlimited speed control parameterap(k) is defined as: ⎧(1− 2−4 )a −3 −3p (k −1) + 2 , if dms (k) − dml (k) ≥ 2 dml (k) ⎪ ⎪(1− 2−4 )a p (k −1) + 2−3 , if y(k) < 3ap(k) = ⎪ ⎨(1− 2−4 )a p (k −1) + 2−3 , if td (k) = 1 ⎪ ⎪1, if tr (k) = 1 ⎩⎪(1− 2−4 )a p (k −1), else, The following variables (short- and long-term averages ofFI(k) ) are needed in calculation ofap: dms (k) = (1− 2−5 )dms (k −1) + 2−5FI(k) dml (k) = (1− 2−7 )dml (k −1) + 2−7FI(k) Values forFI(k) are fetched from static table (see Appendix A). 8.4 Tone And Transition Detector Tone detection: ⎧1, if a2 (k) < −0.71875td = ⎨ ⎩0, else Transition detection: ⎧ t 1, if a2 (k −1) < −0.71875 and d yl (k−1) = ⎨ q (k) > 24 * 2 r ⎩0, else 8.5 Adaptive Predictor Signal estimate: se (k) = sep + sez where sep = ∑ai (k −1)sr (k − i) i=1 and sez = ∑bj (k −1)dq (k − j) j=1 A-coefficient updating: a1(k) = (1− 2 −8 )a1(k −1) + 3* 2 −8 * sgn( p(k)) sgn( p(k −1)) a2 (k) = (1− 2 −7 )a2 (k −1) + 2−7 *{sgn( p(k))sgn( p(k − 2)) − f (a1(k −1))sgn( p(k))sgn( p(k −1))} where p(k ) =d q(k ) + sez (k ) , ⎧4a1 , if a1 ≤ 0.5f (a1 ) = ⎨ ⎩2sgn(a1 ), if a1 > 0.5 Limitation: a2 (k ) ≤ 0.75 and a1(k ) ≤1− 2−4 − a2 (k ) 12 AVR336,

AVR336

B-coefficient updating, when ADPCM-code is 2, 3, or 4-bit: bi (k ) = (1− 2−8 )bi (k −1)+ 2−7 sgn[dq (k )]sgn[dq (k − i)] B-coefficient updating, when ADPCM-code is 5-bit: b (k ) = (1− 2−9i )bi (k −1)+ 2−7 sgn[dq (k )]sgn[dq (k − i)] If a transition is detected: ⎧a (k) = 0, i = 1,2 tr = 0 ⇒ i ⎨ ⎩bi (k) = 0, i = 1..6 8.6 Reconstructed Signal Calculator The reconstructed signal sr (k) is calculated by simply adding the signal estimate to the difference signal: sr (k ) = se (k ) + dq (k ), 9 Appendix C: Filter Circuit The filter illustrated in the figure below is a second-order, low-pass, Butterworth filter with Sallen-Key topology. The cut-off frequency is at 3000 Hz. The PWM base frequency, 31.25 kHz, is attenuated by about 40 dB. The filter is implemented using a single-sided low-voltage operational amplifier TS921, which can be used with operating voltages ranging from 2.7 to 12 V. Figure 9-1. Filter Schematics Error! Not a valid link. Gain and operating voltage Vcc may need adjustments depending on the load, RL. A suitable operating voltage for this configuration is +5V. Table 9-1. Filter Component Values. Component Value Description R1 1,69 kΩ Butterworth filter resistor R2 3,4 kΩ Butterworth filter resistor C1 0,022 µF Butterworth filter capacitor C2 0,022 µF Butterworth filter capacitor C3 1 µF DC coupling capacitor IC1 TS921 Operational amplifier RL ≥ 32 Ω (1) Miniature speaker, headphones, etc. (1) Depends on IC1. See manufacturer’s datasheet. 14 AVR336,

AVR336

10 Appendix D: Files Included This section lists the files distributed with the application note. 10.1 Decoder The file “data.c” contains the encoded sound recording. To experiment with different recordings, delete data.c, copy one of the files from the “Samples”-directory to the source directory, rename it to “data.c” and change the BITS and INPUTSIZE parameters from the file “adpcm.h” accordingly. Then compile and link the program. Decoder files are located in the Source\Decoder directory. Table 10-1. Decoder Files. File Name Description adpcm.c ADPCM algorithms adpcm.h ADPCM header file AVR336.eww IAR workspace/project file data.c Encoded sound data file (see header for information) Decoder.ewp IAR workspace/project file main.c Main program update_yl.asm ASM routine to update scale factor 10.2 Encoder The encoder files are located in the Source\Tools directory. Table 10-2. Encoder Files. File Name Description decode.c Source code for decoder decode.exe Compiled decoder encode.c Source code for encoder encode.exe Compiled encoder g7*.* Supporting source code files for encoder and decoder c-izer.cpp Source code for text file to C code converter c-izer.exe Compiled text file to C code converter Portions of software based on code released to public domain by Sun Microsystems®, Inc., 10.3 Sound Samples Sound samples are located in the Source\Samples directory. Table 10-3. Sound Samples. File Name Technical Details Example_5bit.c ADPCM, 5-bit, 7.8 kHz Example_4bit.c ADPCM, 4-bit, 7.8 kHz Example_3bit.c ADPCM, 3-bit, 7.8 kHz Example_2bit.c ADPCM, 2-bit, 7.8 kHz 16 AVR336,

AVR336

11 Appendix E: Generating ADPCM Files An ADPCM encoder is needed to produce the packed files for the decoder described in this application note. The decoder will decode data, which has ben packed with any standard-compliant ADPCM encoder but in order to obtain highest possible quality it is recommended to use a customised, non-standard encoder for generating the ADPCM sound files. This is because the decoder doesn’t strictly follow the ITU-T standard (see chapter Compliance with ITU-T G.726). The operating principle of the encoder is briefly explained on page 2. 11.1 Using the Encoder Included with this application note is a pre-compiled encoder, which can be run on a PC with Windows® operating systems. The encoder is run from the command line with the following parameters: encode [-2|3|4|5] [-a|u|l] –i infile -o|c outfile -2 Generate G.726 16kbps (2-bit) data -3 Generate G.726 24kbps (3-bit) data -4 Generate G.726 32kbps (4-bit) data [default] -5 Generate G.726 40kbps (5-bit) data -a Process 8-bit A-law input data -u Process 8-bit u-law input data -l Process 16-bit linear PCM input data [default] -i Input filename (binary) -o Output filename (binary) -c Output filename (text file in format ready to be pasted into a c-array) For example: the following command line instructs the encoder to use 32 kbps ADPCM to encode a 16-bit linear PCM file called “sound1.bin” to a text file named “encoded1.txt”: encode –4 –l -i sound1.bin –c encoded1.txt The output file contains a hex listing, as follows (hex data is only an example of what the output may look like): 0xef, 0xc1, 0xff, 0xde, 0x7b, 0xff, 0xff, 0xff, 0xfe, 0xfb, 0xff, 0xff, 0xf7, 0xfe, 0x7f, 0xff, ..., The text file must then be formatted into a valid *.c file, which can be used when compiling the ADPCM decoder project. For this purpose, add lines shown in bold below (hex data is still just an example): #pragma memory = _hugeflash char packed_ [] = { 0xef, 0xc1, 0xff, 0xde, 0x7b, 0xff, 0xff, 0xff, 0xfe, 0xfb, 0xff, 0xff, 0xf7, 0xfe, 0x7f, 0xff, … 0x10, 0xf1, 0x45, 0x21, 0x44, 0x8c, 0xff, 0xff, 0xff }; #pragma memory = default char _hugeflash *packed = packed_; Note that the command line encoder generates hex output files that end with a comma. Make sure the array data does not end with a comma. Save the file as data.c and copy it to the source directory of the ADPCM decoder. Finally, count the number of elements in the array and use this number to configure the INPUTSIZE parameter of file adpcm.h (see section “Implementation Example”). Each full line of elements contains eight (8) characters of data. To quickly count the total lines use a plain text editor that indicates on which line the cursor is when editing and move the cursor from the first line to the last. A small application named C-IZER is also included. It performs all necessary operations described above for creating a valid C-file from the text file generated by ENCODE. The application also returns the value for the INPUTSIZE parameter. 11.2 Using WAV-Files WAV is a sound format developed by Microsoft® and used extensively in Microsoft Windows®. Conversion tools are available to allow most other operating systems to play WAV-files. The encoder included with this application note can be used to convert WAV-files to ADPCM records, which can then be played back from the target AVR. In order to use WAV-files with the ADPCM encoder, the files should be saved as 16- bit PCM in mono. The default settings of the decoder rely on a sampling frequency of 7.8 kHz. WAV-files include a header, which the ADPCM encoder does not differentiate from sound data. This means that the encoded sound file may start with a few bytes that actually represent header data processed as sound samples. Typically, this is not audible and the WAV-file header can usually be simply disregarded. 11.3 Compiling the Encoder The encoder must be recompiled if it is to be used on other platforms than Windows® PC. Source codes are included with the application note. 18 AVR336,

AVR336

12 References 1. Atmel Application Note AVR335: Digital Sound Recorder with AVR® and DataFlash®. http://www.atmel.com 2. ITU-T Recommendation G.726: 40, 32, 24, 16 kbit/s Adaptive Differential Pulse Code Modulation (ADPCM). http://www.itu.int 3. ANSI-C Implementations of CCITT G.711, G.721 and G.723 Voice Compressions by Sun Microsystems, Inc. ftp://ftp.cwi.nl/pub/audio/ccitt-adpcm.tar.gz,

Disclaimer Atmel Corporation Atmel Operations

2325 Orchard Parkway Memory RF/Automotive San Jose, CA 95131, USA 2325 Orchard Parkway Theresienstrasse 2 Tel: 1(408) 441-0311 San Jose, CA 95131, USA Postfach 3535 Fax: 1(408) 487-2600 Tel: 1(408) 441-0311 74025 Heilbronn, Germany Fax: 1(408) 436-4314 Tel: (49) 71-31-67-0

Regional Headquarters Microcontrollers Fax: (49) 71-31-67-2340 Europe 2325 Orchard Parkway 1150 East Cheyenne Mtn. Blvd.

Atmel Sarl San Jose, CA 95131, USA Colorado Springs, CO 80906, USA Route des Arsenaux 41 Tel: 1(408) 441-0311 Tel: 1(719) 576-3300 Case Postale 80 Fax: 1(408) 436-4314 Fax: 1(719) 540-1759 CH-1705 Fribourg Switzerland La Chantrerie Biometrics/Imaging/Hi-Rel MPU/ Tel: (41) 26-426-5555 BP 70602 High Speed Converters/RF Datacom Fax: (41) 26-426-5500 44306 Nantes Cedex 3, France Avenue de Rochepleine Tel: (33) 2-40-18-18-18 BP 123

Asia Fax: (33) 2-40-18-19-60 38521 Saint-Egreve Cedex, France

Room 1219 Chinachem Golden Plaza ASIC/ASSP/Smart Cards Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 77 Mody Road Tsimshatsui Zone Industrielle East Kowloon 13106 Rousset Cedex, France Hong Kong Tel: (33) 4-42-53-60-00 Tel: (852) 2721-9778 Fax: (33) 4-42-53-60-01 Fax: (852) 2722-1369 1150 East Cheyenne Mtn. Blvd.

Japan Colorado Springs, CO 80906, USA

9F, Tonetsu Shinkawa Bldg. Tel: 1(719) 576-3300 1-24-8 Shinkawa Fax: 1(719) 540-1759 Chuo-ku, Tokyo 104-0033 Japan Scottish Enterprise Technology Park Tel: (81) 3-3523-3551 Maxwell Building Fax: (81) 3-3523-7581 East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743

Literature Requests

www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL’S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL’S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Atmel’s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. © Atmel Corporation 2004. All rights reserved. Atmel®, logo and combinations thereof, AVR®, and AVR Studio® are registered trademarks, and Everywhere You AreSM are the trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.]
15

Similar documents

8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 1181B–AVR–04/03 AVR360: Step Motor Controller Features • High-speed Step Motor Controller • Interrupt Driven • Compact Code (Only 10 Bytes Interrupt Routine) • Very High Speed • Low Computing Requirement • Supports all AVR Devices Introduction This applica
8-bit RISC Microcontroller Application Note AVR335: Digital Sound Recorder with AVR and Serial DataFlash Features
8-bit RISC Microcontroller Application Note Rev. 1456B–01/04 AVR335: Digital Sound Recorder with AVR and Serial DataFlash Features • Digital Voice Recorder • 8-bit Sound Recording • 8 KHz Sampling Rate • Sound Frequency up to 4000 Hz • Maximum Recording Time 2 1/4 Minutes • Very Small Board Size • O
USB in a Nutshell. Making Sense of the USB Standard.
USB in a Nutshell. Making Sense of the USB Standard. Starting out new with USB can be quite daunting. With the USB 2.0 specification at 650 pages one could easily be put off just by the sheer size of the standard. This is only the beginning of a long list of associated standards for USB. There are U
What is USB Enumeration? What does enumeration look like?
What is USB Enumeration? Enumeration is the process by which a USB device is attached to a system and is assigned a specific numerical address that will be used to access that particular device. It is also the time at which the USB host controller queries the device in order to decide what type of d
Draft
CYCLIC REDUNDANCY CHECKS IN USB Introduction The USB specification calls for the use of Cyclic Redundancy Checksums (CRC) to protect all non-PID fields in token and data packets from errors during transmission. This paper describes the mathematical basis behind CRC in an intuitive fashion and then e
File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_ATmega8\AVR Studio 4 project\USBtoRS232.asm 1.2.2004
1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USBtoRS232.asm" 5 ;* Title :AVR309:USB to UART protocol converter 6 ;* Date :01.02.2004 7 ;* Version :2.8 8 ;* Target MCU :ATmega8 9 ;* AUTHOR :Ing. Igor Cesko 10 ;* Slovak
File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_AT90S2313\AVR Studio 4 project\USB90S2313.asm 26.1.2004
1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USB90S2313.asm" 5 ;* Title :AVR309:USB to UART protocol converter (simple - small FIFO) 6 ;* Date :26.01.2004 7 ;* Version :2.2 8 ;* Target MCU :AT90S2313-10 9 ;* AUTHOR :I
AVR309: Software Universal Serial Bus (USB)
AVR309: Software Universal Serial Bus (USB) Features • USB (Universal Serial Bus) protocol implemented in firmware • Supports Low Speed USB (1.5Mbit/s) in accordance with USB2.0 • Implementation runs on very small AVR devices, from 2kBytes and up • Few external components required - One resistor for
Application Note
8-bit Microcontrollers Application Note AVR270: USB Mouse Demonstration Features • Runs with AT90USB Microcontrollers at 8MHz • USB Low Power Bus Powered Device (less then 100mA) • Supported by any PC running Windows® (98SE or later), Linux® or Mac OS®. • 3Kbytes of Code Required • X, Y Movement, Le
8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 2547A–AVR–11/03 AVR244: AVR UART as ANSI Terminal Interface Features • Make use of standard terminal software as user interface to your application. • Enables use of a PC keyboard as input and ascii graphic to display status and control information. • Driv
MPASM USER'S GUIDE with MPLINK and MPLIB MPASM USER'S GUIDE with MPLINK and MPLIB
Adjust Spine to fit MPASM USER'S GUIDE with MPLINK and MPLIB Microchip Technology Inc. 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 602.786.7200 Fax: 602.899.9210 © 1999 Microchip Technology Inc., Printed in the U.S.A. 3/99 DS33014 MPASM USER'S GUIDE with MPLINK and MPLIB Information only.
Microcontroller Core Features: RA5/SS/AN4 7 34 RB1RE0/RD/AN5 8 33 RB0/INT
Device Pins A/D PSP Pin Diagram PIC16C63A 28 NO NO PDIP, Windowed CERDIP PIC16C73B 28 YES NO MCLR/VPP 1 40 RB7 PIC16C65B 40 NO YES RA0/AN0 2 39 RB6 RA1/AN1 3 38 RB5 PIC16C74B 40 YES YES RA2/AN2 4 37 RB4 RA3/AN3/VREF 5 36 RB3 RA4/T0CKI 6 35 RB2 Microcontroller Core Features: RA5/SS/AN4 7 34 RB1RE0/RD
PACKAGE OPTION ADDENDUM
PCM2704 and PCM2705 Not Recommended For New Designs PCM2704, PCM2705 PCM2706, PCM2707 Burr-Brown Audio www.ti.com... SLES081F–JUNE 2003–REVISED JANUARY 2009 STEREO AUDIO DAC WITH USB INTERFACE, SINGLE-ENDED HEADPHONE OUTPUT AND S/PDIF OUTPUT 1FEATURES – External ROM Interface (PCM2704/6) 2345• On-Ch
14 + 14W STEREO AMPLIFIER WITH MUTE & ST-BY
TDA7269A 14 + 14W STEREO AMPLIFIER WITH MUTE & ST-BY WIDE SUPPLY VOLTAGE RANGE UP TO ±20V SPLIT SUPPLY HIGH OUTPUT POWER 14 + 14W @ THD =10%, RL = 8Ω, VS = +16V NO POP AT TURN-ON/OFF MUTE (POP FREE) STAND-BY FEATURE (LOW Iq) SHORT CIRCUIT PROTECTION TO GND THERMAL OVERLOAD PROTECTION Multiwatt11 OR
FOREWORD This repair manual has been prepared to provide essential in-
FOREWORD This repair manual has been prepared to provide essential in- formation on body panel repair methods (including cutting and welding operations, but excluding painting) for the TOYOTA YARIS. Applicable models: KSP90 series Applicable models: NCP90, 91 series This manual consists of body repa
MPASM and MPLINK PICmicro® QUICK REFERENCE GUIDE
MPASM and MPLINK PICmicro® QUICK REFERENCE GUIDE The Embedded Control Solutions Company® MPASM Quick Reference Guide This Quick Reference Guide gives all the instructions, directives, and command line options for the Microchip MPASM Assembler. MPASM Directive Language Summary Directive Description S
M INTRODUCTION
M Author: Mark Palmer Microchip Technology Inc. INTRODUCTION The PICmicro™ families of RISC microcontrollers are designed to provide advanced performance and a cost-effective solution for a variety of applications. To address these applications, there is the PIC16CXXX microcontroller family of produ
M ENGINE ON-VEHICLE INSPECTION ASSEMBLY
1NZ-FE ENGINE MECHANICAL – ENGINE EM–1 M ENGINE ON-VEHICLE INSPECTION 1. INSPECT ENGINE COOLANT (See page CO-1) 2. INSPECT ENGINE OIL (See page LU-1) 3. INSPECT BATTERY (See page CH-4) 4. INSPECT AIR CLEANER FILTER ELEMENT SUB- ASSEMBLY (a) Remove the air cleaner filter element sub-assembly. (b) Vis
FOREWORD This wiring diagram manual has been prepared to provide information on the electrical system of the 2007 YARIS. Applicable models: NCP91, 93 Series
FOREWORD This wiring diagram manual has been prepared to provide information on the electrical system of the 2007 YARIS. Applicable models: NCP91, 93 Series Refer to the following manuals for additional service specifications and repair procedures for these models: Manual Name Pub. No. 2007 YARIS Re
X AUTOMATIC TRANSAXLE SYSTEM PRECAUTION
U340E AUTOMATIC TRANSAXLE – AUTOMATIC TRANSAXLE SYSTEM AX–1 X AUTOMATIC TRANSAXLE SYSTEM PRECAUTION NOTICE: • Perform the RESET MEMORY (AT initialization) when replacing the automatic transaxle assembly, engine assembly or ECM (See page AX-14). • Perform the REGISTRATION (VIN registration) when repl
ON Semiconductor 2N5550 Amplifier Transistors NPN Silicon 2N5551*
ON Semiconductor 2N5550 Amplifier Transistors NPN Silicon 2N5551* *ON Semiconductor Preferred Device MAXIMUM RATINGS Rating Symbol 2N5550 2N5551 Unit Collector–Emitter Voltage VCEO 140 160 Vdc Collector–Base Voltage VCBO 160 180 Vdc Emitter–Base Voltage VEBO 6.0 Vdc Collector Current — Continuous IC
GENERAL DESCRIPTION QUICK REFERENCE DATA PINNING - TO92 variant PIN CONFIGURATION SYMBOL
GENERAL DESCRIPTION QUICK REFERENCE DATA Glass passivated sensitive gate SYMBOL PARAMETER MAX. UNIT thyristor in a plastic envelope, intended for use in general purpose VDRM, Repetitive peak off-state voltages 200 V switching and phase control VRRM applications. This device is intended IT(AV) Averag
N-Channel JFETs
N-Channel JFETs 2N4117A PN4117A SST4117 2N4118A PN4118A SST4118 2N4119A PN4119A SST4119 Part Number VGS(off) (V) V(BR)GSS Min (V) gfs Min (S) IDSS Min (A) 4117 –0.6 to –1.8 –40 70 30 4118 –1 to –3 –40 80 80 4119 –2 to –6 –40 100 200 Ultra-Low Leakage: 0.2 pA Insignificant Signal Loss/Error Voltage
Order this document SEMICONDUCTOR TECHNICAL DATA by 2N3903/D NPN Silicon
Order this document SEMICONDUCTOR TECHNICAL DATA by 2N3903/D NPN Silicon *Motorola Preferred Device COLLECTOR BASE EMITTER 1 MAXIMUM RATINGS Rating Symbol Value Unit CASE 29–04, STYLE 1 TO–92 (TO–226AA) Collector–Emitter Voltage VCEO 40 Vdc Collector–Base Voltage VCBO 60 Vdc Emitter–Base Voltage VEB
DISCRETE SEMICONDUCTORS DATA SHEET 2N2222; 2N2222A NPN switching transistors Product specification 1997 May 29 Supersedes data of September 1994 File under Discrete Semiconductors, SC04
DISCRETE SEMICONDUCTORS DATA SHEET M3D125 2N2222; 2N2222A NPN switching transistors Product specification 1997 May 29 Supersedes data of September 1994 File under Discrete Semiconductors, SC04 FEATURES PINNING • High current (max. 800 mA) PIN DESCRIPTION • Low voltage (max. 40 V). 1 emitter 2 base A
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide V TYPE CEO IC Ptot fhhTPNP PACKAGE max. max. max. FE FE min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) BC846 SOT23 65 100 250 110 450 100 BC856 305 BC846A SOT23 65 100 250 110 220 100 BC856A 305 BC846AT SC-75 65 100 150 110 220 1
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide SURFACE-MOUNT DEVICES NPN GENERAL PURPOSE LOW-POWER TRANSISTORSVIPfTYPE CEO C tothhTPNP PACKAGE max. max. max. FE FE min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) 2PC4081 SC-70 40 100 200 120 560 100 2PA1576 210 2PC4081Q SC-70 4
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide LEADED DEVICES (continued) NPN HIGH-VOLTAGE POWER TRANSISTORSVIPfTYPE CEO C tothhTPACKAGE max. max. max. FE FE PNP min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) BF419 TO-126 250 300 6000 45 typ. >45 90 – 532 BF457 TO-126 160 100
DISCRETE SEMICONDUCTORS DATA SHEET 1PS302 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS302 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Very small plastic SMD package The 1PS302 consists of two PIN DESCRIPTION • High switching speed: max.
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide LEADED DEVICES NPN GENERAL PURPOSE LOW-POWER TRANSISTORSVIPfTYPE CEO C tothhTPACKAGE max. max. max. FE FE PNP min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) 2N2484 TO-18 60 50 360 250 800 60 – 131 2N4124 TO-92 25 200 500 120 360