Home

ADSP-2100 Family C Runtime Library Manual

image

Contents

1. stringl 2 0 strcat stringl CD new string is ABCD SEE ALSO strncat compare strings strcmp FUNCTION strcmp compare strings SYNOPSIS include lt string h gt int strcmp const char sl const char s2 DESCRIPTION The strcmp function compares lexicographically the null terminated strings pointed toby s1 and s2 It returns a positive value if the s1 string is greater than the s2 string a negative value ifthe s2 string is greater than the s1 string and a zero if the strings are the same ERROR CONDITIONS The strcmp function does not return an error condition EXAMPLE include lt string h gt char stringl 50 string2 50 if stremp stringl string2 printf s is different than s Nn stringl string2 SEE ALSO memcmp strncmp strcpy copy from one string to another FUNCTION strcpy copy from one string to another SYNOPSIS include lt string h gt void strcpy char _const_ char DESCRIPTION The strcpy function copies the null terminated string pointed to by s2 into the space pointed to by s1 Memory allocated for s1 must be large enough to hold s2 plus one space for the null character 0 The behavior of strcpy is undefined if the two objects overlap orif sl isnotlarge enough The strcpy function returns the new SL FRROR CONDITIONS The strcpy function does not return an error condition EXAMPLE include lt string h gt
2. log 1 0 y 0 0 SEE ALSO exp log log10 base 10 logarithm log10 FUNCTION log10 base 10 logarithm SYNOPSIS include lt math h gt double log10 double DESCRIPTION The 10910 function produces the base 10 logarithm of its input and returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 2 20 over its input range ERROR CONDITIONS The 10910 function indicates a domain error set errno to EDOM and returns a zero if the input is negative EXAMPLE include lt math h gt double y y logl0 100 0 y 2 0 SEE ALSO log pow L 33 L 34 memcmp compare objects FUNCTION memcmp compare objects SYNOPSIS include lt string h gt int memcmp const void sl const void s2 size_t n DESCRIPTION The memcmp function compares the first n characters of the objects pointed toby s1 and s2 It returns a positive lexical value if the s1 object is greater than the s2 object If the s2 object is greater than the s1 object a negative value is returned A zero is returned if the objects are the same ERROR CONDITIONS The memcmp function does not return an error condition EXAMPLE include lt string h gt char stringl ABC char string2 BCD result memcmp stringl string2 3 result lt 0 SEE ALSO strcmp strncmp copy characters from memcpy one object to another FUNCTION memc
3. char stringl 50 1 strepy stringl SOMEFUN SOMEFUN is copied into stringl SEE ALSO memcpy strncpy string length strlen FUNCTION strlen string length SYNOPSIS include lt string h gt size t strlen const char sl DESCRIPTION The strlen function returns the length of the null terminated string pointed to by s not including the null ERROR CONDITIONS e strlen function does not return an error condition EXAMPLE include lt string h gt size t len len strlen SOMEFUN len 7 SEE ALSO No references to this function strncat concatenate characters from one string to another FUNCTION strncat concatenate characters from one string to another SYNOPSIS include lt string h gt char strncat char sl const char s2 size t n DESCRIPTION The strncat function appends a copy of up to n characters in the null terminated string pointed to by s2 to the end of the null terminated string pointed to by s1 It returns a pointer to the new s1 string The behavior of strncat is undefined if the two strings overlap The new s1 string is terminated with a null 0 ERROR CONDITIONS e strncat function does not return an error condition EXAMPLE include lt string h gt char stringl 50 ptr string 0 0 strncat stringl MOREFUN 4 stringl equals MORE SEE ALSO strcat compare characters in strings strncmp FUNCTI
4. difference between them is the size of the arrays on which they operate To call a particular function substitute the number of points for N for example ifft8 r inp i_inp r_outp i_outp not ifftN r inp i_inp r_outp i_outp The inputto ifftN isa integer array of N points If there are fewer than N actual data points you must pad the array with zeros to make N samples Better results occur with less zero padding however The input data should be windowed if necessary before calling the function because no preprocessing is performed on the data The functions return a pointer to the real output array ERROR CONDITIONS The ifftN functions do not return error conditions EXAMPLE include lt fft h gt define N 2048 int i int real_input N imag_input N imag_output N int real_output N Real input array is filled from a previous fft2048 or other source ifft2048 real input imag_input real output imag output 7 Arrays are filled with FFT data SEE ALSO fftN infinite impulse response IIR filter iir FUNCTION iir infinite impulse response IIR filter SYNOPSIS include lt filters h gt int iir float sample int pm a_coeffs int pm b_coeffs int dm state int taps DESCRIPTION This function is an Analog Devices extension to the ANSI standard The iir function implements an infinite impulse HR filter defined by the coefficients and delay line that are
5. and delay line that are supplied in the call of fir The function produces the filtered response of its input data This FIR filter is structured as a sum of products The characteristics of the filter passband stop band etc are dependent on the coefficient values and the number of taps supplied by the calling program The integer input to the filter is sample The integer taps indicates the length of the filter which is also the length of the array coeffs The coeffs array holds one FIR filter coefficient per element The coefficients are stored in reverse order for example coeffs 0 holds the taps 1 coefficient The coeffs array is located in program memory data space to use the single cycle dual memory fetch of the processor The state array contains a pointer to the delay line as its last element B by the delay line values The length of the state array is therefore 1 greater than the number of taps Each filter has its own state array which should not be modified by the calling program only by the fir function The state array should be initialized to zeros before the fir function is called for the first time The parameters sample coeffs and state are all considered to be fractional numbers The fir executes fractional multiples that preserve the format of the fractional input If your application requires a true integer fir you should divide the ouput of the filter by two fir finite impulse response FIR fil
6. h has 1 2 CHAPTER 2 USING LIBRARY FUNCTIONS 2 1 CALLING FUNCTIONS nn nn sun 2 1 2 1 1 Header PISS esi a n ay baa Eee 2 1 2 1 2 Bullen F nctllofiSu a a a a aa aaa y SS 2 1 2 2 LIBRARY DIRECTORY el mA re der 2 2 2 3 LIBRARY SOURCE CODE users alle 2 2 CHAPTER 3 LIBRARY STRUCTURE 3 1 ANSI RUNTIME ENVIRONMENT MACROS amp DEFINITIONS 3 1 3 2 ANSI STANDARD FUNCTIONS a ee 3 1 CHAPTER 4 HEADER FILES 4 1 OVERVIEW eines 4 1 4 2 float h FLOATING POINT ess a 4 1 43 MER h DSPEILTERS saadan 4 1 4 4 math h MATHEMATICS An een 4 1 4 5 signal h SIGNAL amp INTERRUPT HANDLING een 4 2 vi Contents LIBRARY FUNCTIONS amp DESCRIPTIONS abs acos asin atan atan2 ceil cos cosh demean buffer exp fabs fftN fir floor fmod frexp ifftN lir interrupt isalpha isdigit labs Idexp log log10 memcmp memcpy memset modf pow raise signal sin sinh sqrt strcat strcmp strcpy strlen strncat strncmp absolute VAE se ce ee ts is L 1 AFC EE EE ET DE a and L 2 CMR L 3 CMJ uren L 4 arc tangent of quotient Eg L 5 Cel RE a aa L 6 COSINE S a a moe a ded are ed L 7 hyperbole COSINE een een L 8 remove the mean of a data buffer L 9 OPE as a ua re a ee L 11 float absolute Valle Ans on data L 12 N point complex input fast Fourier transform FFT L 13 finite impulse response FIR fil
7. is equal to the next argument in ap SEE ALSO va start va end reset variable list pointer va end FUNCTION va end reset variable list pointer SYNOPSIS include lt stdarg h gt void va end va list ap DESCRIPTION The va end macro can only be used after the va start macro has been invoked The va end macro resets the pointer initialized by va start This is necessary for a proper return from the function in which the macros are invoked ERROR CONDITIONS The va end macro does not return an error condition EXAMPLE include lt stdarg h gt va list ap va end ap SEE ALSO va arg va start L 60 va_start set variable list pointer FUNCTION va_start set variable list pointer SYNOPSIS include lt stdarg h gt void va_start va_list ap parmN DESCRIPTION The va_start macro should be invoked in a function that requires a variable number of arguments The va_start macro initializes a poe of type va_list to point to an argument that immediately ollows the last required named parameter in the functions argument list This last required parameter is provided as an argument in the invocation of va_start The va_start macro must be invoked before either the va_arg or va_end macro can be invoked ERROR CONDITIONS The va_start macro does not return an error condition EXAMPLE include lt stdarg h gt va_list ap va_start ap last_required_argument SEE ALSO va_arg va_end
8. must be one of the following signals listed below in priority order Signal Value Meaning SIG_IGN Signal Ignore SIG_DFL Signal Default SIG_ERR Signal Error SIGINT3 Interrupt 3 lt ADSP 2100 Only gt SIGINT2 Interrupt 2 SIGINT1 Interrupt 1 SIGINTO Interrupt 0 SIGSPORTOXMIT Signal Sport 0 Transmit lt Not ADSP 2100 gt SIGSPORTORECV Signal Sport 0 Receive SIGTIMER Signal Timer SIGSPORTIXMIT Signal Sport 1 Transmit lt Not ADSP 2100 gt SIGSPORTIRECV Signal Sport 1 Receive lt Not ADSP 2100 gt SIGHIPWRITE Signal HIP Write lt ADSP 2111 ADSP 2150 ADSP 2171 Only gt SIGHIPREAD Signal HIP Read lt ADSP 2111 ADSP 2150 ADSP 2171 Only gt SIGPOWERDOWN Signal Power Down lt ADSP 2150 ADSP 2171 gt SIGCODECXMIT Signal Codec Transmit lt ADSP 2150 Only gt SIGCODECREC Signal Codec Record lt ADSP 2150 Only gt SIGSWI1 Signal Software Interupt 1 lt ADSP 2171 Only gt SIGSWIO Signal Software Interupt 0 lt ADSP 2171 Only gt Note Interrupts are nested by default L 39 raise force a signal ERROR CONDITIONS ce raise function returns a zero if successful a nonzero value if it ails EXAMPLE include lt signal h gt raise SI cm DFL invoke the signal default SEE ALSO interrupt signal define signal handling signal FUNCTION signal define signal handling SYNOPSIS include lt signal h gt void signal int sig void func int int DESCRIPTION The signal function determine
9. supplied in the call of iir The function produces the filtered response of its input data The IIR filter implemented in this function is based on the Oppenheim and Schafer Direct Form II The characteristics of the filter depend on the coefficient values supplied by the calling program The integer input to the filter is sample The integer taps indicates the length of the filter which is the length of the arrays a_coeffs b_coeffs and delay The a_coeffs and b_coeffs arrays hold one IIR filter coefficient per element The coefficients are stored in reverse order for example a_coeffs 0 holdsthe taps 1 the last coefficient The state array contains a pointer to the delay line as its last element pe by the delay line values The length of the state array is therefore 1 greater than the number of taps Each filter has its own state array which should not be modified by the calling program only by the iir function The state array should be initialized to zeros before the iir function is called for the first time infinite impulse response IIR filter The flow graph below corresponds to the iir routine as part of the C Runtime Library iir b_coeffs TAPS sample amre e o output b_coeffs TAPS 1 a_coeffs TAPS 1 b_coeffs TAPS 2 a_coeffs TAPS 2 b_coeffs TAPS 3 a_coeffs TAPS 3 b_coeffs 0 a_coeffs 0 The b_coeffs arrays should equal length TAPS 1 he a
10. 8 distinct functions in this set They all perform the same function with the same type and number of arguments The only difference between them is the size of the arrays on which they operate To call a particular function substitute the number of points for N for example fft8 r inp i inp r outp i outp not fftN r inp i inp r outp i outp Theinputto fftN is a integer array of N points If there are fewer than N actual data points you must pad the array with zeros to make N samples Better results occur with less zero padding however The input data should be windowed if necessary before calling the function because no preprocessing is performed on the data The functions return a block exponent ERROR CONDITIONS The fftN functions do not return error conditions EXAMPLE include lt fft h gt define N 1024 int in in i real_input N imag_input N imag_output N real_output N ara fft1024 real_input imag_input real_output imag_output Arrays are filled with FFT data SEE ALSO ifftN finite impulse response FIR filter fir FUNCTION fir finite impulse response FIR filter SYNOPSIS include lt filters h gt int fir int sample int pm coeffs int dm state int taps DESCRIPTION This function is an Analog Devices extension to the ANSI standard The fir function implements a finite impulse response FIR filter defined by the coefficients
11. ADSP 2100 Family C Runtime Library Manual ADSP 2100 Family C Runtime Library Manual 1994 Analog Devices Inc ALL RIGHTS RESERVED PRODUCT AND DOCUMENTATION NOTICE Analog Devices reserves the right to change this product and its documentation without prior notice Information furnished by Analog Devices is believed to be accurate and reliable However no responsibility is assumed by Analog Devices for its use nor for any infringement of patents or other rights of third parties which may result from its use No license is granted by implication or otherwise under the patent rights of Analog Devices PRINTED IN U S A Printing History SECOND EDITION 11 94 For marketing information or Applications Engineering assistance contact your local Analog Devices sales office or authorized distributor If you have suggestions for how the ADSP 2100 Family development tools or documentation can better serve your needs or you need Applications Engineering assistance from Analog Devices please contact Analog Devices Inc DSP Applications Engineering One Technology Way Norwood MA 02062 9106 Tel 617 461 3672 Fax 617 461 3010 e mail dsp_applications analog com Or log in to the DSP Bulletin Board System Telephone number 617 461 4258 300 1200 2400 9600 baud no parity 8 bits data 1 stop bit For additional marketing information call 617 461 3881 in Norwood MA USA Literature ADSP 2100 FAMILY MANUA
12. I se T SEE ALSO pow log fabs float absolute value FUNCTION fabs float absolute value SYNOPSIS include lt math h gt double fabs double DESCRIPTION The fabs function returns the absolute value of the argument ERROR CONDITIONS The fabs function does not return an error condition EXAMPLE include lt math h gt double y fabs 2 3 y fabs 2 3 y y 2 3 y 2 3 7 SEE ALSO abs labs N point complex input fftN fast Fourier transform FFT FUNCTION fftN N point complex input fast Fourier transform FFT SYNOPSIS int fft1024 int rl_in int im in int rl_out int im_out int fft5l12 int rl_in int im in int rl_out int im_out int fft256 int rl_in int im in int rl_out int im_out int fft128 int rl_in int im in int rl_out int im_out int fft64 int rl_in int im in int rl_out int im_out int fft32 int rl_in int im in int rl_out int im_out int fftl6 int rl in int im in int rl_out int im_out int fft8 int rl_in int im in int rl out int im out fftN N point complex input fast Fourier transform FFT DESCRIPTION These functions are Analog Devices extensions to the ANSI standard Each of these 8 fftN functions computes the N point radix 2 fast Fourier transform FFT of its integer input where N is 8 16 32 64 128 256 512 or 1024 There are
13. Interrupt 2 Interrupt 1 Interrupt 0 Signal Sport 0 Transmit Signal Sport 0 Receive Signal Timer Signal Sport 1 Transmit Signal Sport 1 Receive lt ADSP 2100 Only gt lt Not ADSP 2100 gt lt Not ADSP 2100 gt lt Not ADSP 2100 gt Signal HIP Write lt ADSP 2111 ADSP 2150 ADSP 2171 Only gt Signal HIP Read lt ADSP 2111 ADSP 2150 ADSP 2171 Only gt Signal Power Down Signal Codec Transmit Signal Codec Record Signal Software Interupt 1 Signal Software Interupt 0 lt ADSP 2150 ADSP 2171 gt lt ADSP 2150 Only gt lt ADSP 2150 Only gt lt ADSP 2171 Only gt lt ADSP 2171 Only gt define interrupt handling interrupt The interrupt function causes the receipt of the signal number func to be handled in one of the following ways func value action SIG_DFL The default action is taken SIG_IGN The signal is ignored Function Address The function pointed to by func is executed The function pointed to by func is executed each time the interrupt is received The interrupt function must be called with the SIG_IGN argument to disable interrupt handling Note Interrupts are nested by default ERROR CONDITIONS The interrupt function returns SIG_ERR andsets errno equal to SIG_ERR if the requested interrupt is not recognized EXAMPLE include lt signal h gt interrupt SIGINT2 int2_handler enable interrupt 2 whose handling routine is pointed to by int2_
14. LS ADSP 2100 Family User s Manual Prentice Hall Complete description of processor architectures and system interfaces ADSP 2100 Family Assembler Tools amp Simulator Manual ADSP 2100 Family C Tools Manual ADSP 2100 Family C Runtime Library Manual Programmer s references ADSP 2100 Family EZ Tools Manual User s manuals for in circuit emulators and demonstration boards APPLICATIONS INFORMATION Digital Signal Processing Applications Using the ADSP 2100 Family Volume 1 Prentice Hall Topics include arithmetic filters FFTs linear predictive coding modem algorithms graphics pulse code modulation multirate filters DTMF multiprocessing host interface and sonar Digital Signal Processing Applications Using the ADSP 2100 Family Volume 2 Prentice Hall Topics include modems linear predictive coding GSM codec sub band ADPCM speech recognition discrete cosine transform digital tone detection digital control system design IIR biquad filters software uart and hardware interfacing SPECIFICATION INFORMATION ADSP 2100 ADSP2100A Data Sheet ADSP 21xx Data Sheet ADSP 21msp50A 55A 56A Data Sheet ADSP 21msp58 59 Preliminary Data Sheet ADSP 2171 72 73 Data Sheet ADSP 2181 Preliminary Data Sheet Contents CHAPTER 1 INTRODUCTION 1 1 OVERVIEW sos aan ne re ENS NS Da ENS Q CA una 1 1 1 2 DOCUMENTATION Kasa 1 1 1 2 1 Notation Conventions l ass 1 1 1 2 2 R f renc FOR lic un ua a alana uqa
15. ON strncmp compare characters in strings SYNOPSIS include lt string h gt int strncmp const char sl const char s2 size t n DESCRIPTION The strncmp function compares lexicographically up to n characters of the null terminated strings pointed to by s1 and s2 It returns a positive value if the s1 string is greater than the s2 string a negative value if the s2 string is greater than the s1 string and a zero if the strings are the same ERROR CONDITIONS The strncmp function does not return an error condition EXAMPLE include lt string h gt char ptrl ptrl TESTI if strncmp ptrl TEST 4 0 printf s starts with TEST Nn ptrl SEE ALSO memcmp strcmp strncpy copy characters from one string to another FUNCTION strncpy copy characters from one string to another SYNOPSIS include lt string h gt char strncpy char sl const char s2 size t n DESCRIPTION The strncpy function copies up to n characters of the null terminated string pointed to by s2 into the space pointed toby s1 If the last character copied from s2 is not a null the result will not end with a null The behavior of strncpy is undefined if the two objects overlap The strncpy function returns the new s1 If the s2 string contains fewer than n characters the s1 string is padded with nulls until all n characters have been written ERROR CONDITIONS The strncpy function does not return an erro
16. _coeffs array should equal length TAPS Adapted from Oppenheim and Schafer Digital Signal Processing New Jersey Prentice Hall 1975 L 24 infinite impulse response IIR filter iir ERROR CONDITIONS The iir function does not return an error condition EXAMPLE include lt filters h gt define TAPS 10 int i int pm a_coeffs TAPS b_coeffs TAPS int in sample output state TAPS 1 for i 0 i lt TAPS 1 i state i 0 initialize state array output iir in sample a coeffs b coeffs state TAPS SEE ALSO fir interrupt FUNCTION define interrupt handling interrupt define interrupt handling SYNOPSIS include lt signal h gt void interrupt int sig DESCRIPTION void func int int This function is an Analog Devices extension to the ANSI standard The interrupt function determines how a signal received during program execution is handled The interrupt function executes the function pointed to by func at every interrupt the signal function executes the function only once The sig argument must be one of the following that are listed in priority order below Signal Value SIG_IGN SIG_DFL SIG_ERR SIGINT3 SIGINT2 SIGINT1 SIGINTO SIGSPORTOXMIT SIGSPORTORECV SIGTIMER SIGSPORT1XMIT SIGSPORTIRECV SIGHIPWRITE SIGHIPREAD SIGPOWERDOWN SIGCODECXMIT SIGCODECREC SIGSWI1 SIGSWIO Meaning Signal Ignore Signal Default Signal Error Interrupt 3
17. c is executed once when the signal is received Handling is then returned to the default state Note Interrupts are nested by default ERROR CONDITIONS The signal functionreturns SIG_ERR andsets errno to SIG_ERR if it does not recognize the requested signal EXAMPLE signal SIG TIMER int handler Executes the function int handler upon receipt of a timer interrupt SEE ALSO interrupt raise sine sin FUNCTION sin sine SYNOPSIS include lt math h gt double sin double DESCRIPTION The sin function returns the sine of x The input is interpreted as a radian the output is in the range 1 1 The sin function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 220 over its input range Although the sin function accepts aie over the entire floating point range the accuracy of the result decreases significantly for an input greater than 712 2 ERROR CONDITIONS The sin function does not return an error condition EXAMPLE include lt math h gt double y y sin 3 14159 y 0 0 SEE ALSO asin cos sinh hyperbolic sine FUNCTION sinh hyperbolic sine SYNOPSIS include lt math h gt double sinh double DESCRIPTION The sinh functions return the hyperbolic sine of x and a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error
18. current value of the TCOUNT register ERROR CONDITIONS e timer_off function does not return an error condition EXAMPLE include lt misc h gt unsigned int hold_tcount hold_tcount timer_off hold_tcount contains value of TCOUNT register AFTER timer has stopped SEE ALSO timer_on timer_set timer on enable ADSP 21XX timer FUNCTION timer on enable ADSP 21xx timer SYNOPSIS include lt misc h gt unsigned int timer on void DESCRIPTION This function is an Analog Devices extension to the ANSI standard The timer on function enables the ADSP 21xx timer and returns the current value of the TCOUNT register ERROR CONDITIONS e timer on function does not return an error condition EXAMPLE include lt misc h gt unsigned int hold_tcount hold_tcount timer_on hold_tcount contains value of TCOUNT register when timer starts SEE ALSO timer_off timer_set initialize ADSP 21XX timer timer set FUNCTION timer set initialize ADSP 21xx timer SYNOPSIS include lt misc h gt int timer set unsigned int tperiod unsigned int tcount int tscale DESCRIPTION This function is an Analog Devices extension to the ANSI standard The timer set function sets the ADSP 21xx timer registers TPERIOD and TCOUNT The function returns a 1 if the timer is enabled a 0 if the timer is disabled The TSCALE value is used to set the TSCALE r
19. egister For a complete description of the ADSP 21xx timer refer to the ADSP 2100 Family User s Guide Note Each interrupt call takes approximately 50 cycles on entrance and 50 cycles on return If tperiod and tcount are set too low you may incur initializing overhead that could create an infinite loop ERROR CONDITIONS The timer set function does not return an error condition EXAMPLE include lt misc h gt if timer_set 1000 1000 1 1 timer on enable timer SEE ALSO timer on timer off va arg get next argument in variable list FUNCTION va_arg get next argument in variable list SYNOPSIS include lt stdarg h gt void va arg va list ap type DESCRIPTION e va arg macro can only be used after the va start macro has been invoked The va arg macro uses the pointer initialized by va start toreturn the value and type of the next argument in the list of optional arguments It then increments the pointer The header file stdarg h defines a pointer type called va list thatis used to access the list of variable arguments The parameter type is a type name such that if a is appended to it then the type of a pointer to an object of type void can be obtained If there isno next variable then there is no defined behavior for va arg ERROR CONDITIONS e va arg macro does not return an error condition EXAMPLE include lt stdarg h gt double y va list ap y va arg ap double y
20. frexp FUNCTION frexp separate fraction and exponent SYNOPSIS include lt math h gt double frexp double int DESCRIPTION The frexp function separates a floating point input into a normalized fraction and a base 2 exponent The function returns the first argument a fraction in the interval 1 and stores a power of 2 in the integer pointed to by the second argument If the input is zero then zeros are stored in both arguments ERROR CONDITIONS The frexp function does not return an error condition EXAMPLE include lt math h gt double y int exponent y frexp 2 0 amp exponent y 0 5 exponent 2 SEE ALSO modf ifftN N point inverse complex input fast Fourier transform IFFT FUNCTION ifftN N point inverse complex input fast Fourier transform IFFT SYNOPSIS include lt trans h gt int int int int int int int int ifft65536 int dm real_input int dm imag_input int dm real_output int dm imag_output ifft32768 int dm real_input int dm imag_input int dm real_output int dm imag_output ifft16384 int dm real input int dm imag_input int dm real_output int dm imag_output ifft8192 int dm real_input int dm imag_input int dm real_output int dm imag_output ifft4096 int dm real_input int dm imag_input int dm real_output int dm imag_output ifft2048 int dm real_i
21. handler interrupt SIGINT2 SIG_IGN disable interrupt 2 SEE ALSO signal raise isalpha detect alphabetic character FUNCTION isalpha detect alphabetic character SYNOPSIS include lt ctype h gt int isalpha int c DESCRIPTION The isalpha function determines if the input is an alphabetic character A Z or a z Ifthe input is not alphabetic isalpha returns a zero If the input is alphabetic isalpha returns a nonzero value ERROR CONDITIONS The isalpha function does not return any error conditions EXAMPLE include lt ctype h gt int ch for ch 0 ch lt 0x7f ch print S 04x ch printf 2s isalpha ch alphabetic W putchar n SEE ALSO isdigit detect decimal digit isdigit FUNCTION isdigit detect decimal digit SYNOPSIS include lt ctype h gt int isdigit int c DESCRIPTION The isdigit function determines if the input character is a decimal digit 0 9 If the input is not a digit isdigit returns a zero If the input is a digit isdigit returns a nonzero value ERROR CONDITIONS e isdigit function does not return an error condition EXAMPLE finclude lt ctype h gt int Ch for ch 0 ch lt 0x7f ch printf S 04x ch printf 2s isdigit ch digit a putchar n SEE ALSO isalpha labs long integer absolute value FUNCTION labs long in
22. l Processing Prentice Hall 1985 demean_buffer returns the mean of the current buffer as a result This value should be passed as a parameter to the function on the next call the first call to demean_buffer should have a 0 for the old_mean value ERROR CONDITIONS The demean_buffer function does not return error conditions EXAMPLE define BUFSIZE 1024 int data_buffer BUFSIZE int data_mean 0 The buffer is filled with data possibly from a 7 converter Remove the mean from the buffer with Ko this demean function data_demean demean_buffer data buffer L 9 demean buffer remove the mean of a data buffer data_mean BUFSIZE Or like this example int i temp_mean temp_mean 0 for i 0 i lt BUFSIZE i temp mean data_buffer i temp mean BUFSIZE for i 0 i lt BUFSIZE i data buffer i temp mean SEE ALSO No references to this function exponential exp FUNCTION exp exponential SYNOPSIS include lt math h gt double exp double DESCRIPTION The exp function computes the exponential value e to the power of its argument ERROR CONDITIONS The exp function returns the value HUGE_VAL and stores the value ERANGE in errno when there is an overflow error In the case of underflow the exp function returns a zero EXAMPLE include lt math h gt double y y exp 1 0 JEU Se SIM
23. nput int dm imag_input int dm real_output int dm imag_output ifft1024 int dm real_input int dm imag_input int dm real_output int dm imag_output ifft5l2 int dm real_input int dm imag_input int dm real_output int dm imag_output N point inverse complex input ifftN fast Fourier transform IFFT int ifft256 int dm real_input int dm imag_input int dm real_output int dm imag_output int ifft128 int dm real_input int dm imag_input int dm real_output int dm imag_output int ifft64 int dm real_input int dm imag_input int dm real_output int dm imag_output int ifft32 int dm real_input int dm imag_input int dm real_output int dm imag_output int ifft16 int dm real input int dm imag_input int dm real_output int dm imag_output int ifft8 int dm real_input int dm imag_input int dm real_output int dm imag_output DESCRIPTION These functions are Analog Devices extensions to the ANSI standard Each of these 14 ifftN functions computes the N point radix 2 inverse fast Fourier transform IFFT of its integer input where N is 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 or 65536 ifftN N point inverse complex input fast Fourier transform IFFT There are 14 distinct functions in this set They all perform the same function with the same type and number of arguments The only
24. of 2 20 over its input range ERROR CONDITIONS For input values greater than 212 the sinh function returns HUGE_VAL andsets errno to ERANGE to indicate overflow EXAMPLE include lt math h gt double x y y sinh x SEE ALSO cosh square root sqrt FUNCTION sqrt square root SYNOPSIS include lt math h gt double sqrt double DESCRIPTION The sqrt function returns the positive square root of x and a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 2 20 over its input range ERROR CONDITIONS The sqrt function returns a zero for a negative input and sets errno to EDOM to indicate a domain error EXAMPLE include lt math h gt double y y Sore 2 0 RO SP Ne Aa ah a 8 Kf SEE ALSO No references to this function strcat concatenate strings FUNCTION strcat concatenate strings SYNOPSIS include lt string h gt char strcat char sl const char s2 DESCRIPTION The strcat function appends a copy of the null terminated string pointed to by s2 to the end of the null terminated string pointed to by s1 Itreturns a pointer to the new s1 string which is null terminated The behavior of strcat is undefined if the two strings overlap PRROR CONDITIONS The strcat function does not return an error condition EXAMPLE include lt string h gt char stringl 50 1 stringl 0 A stringl 1 B
25. ons Header Purpose errno h Error Handling stddef h Standard Definitions limits h Limits float h Floating Point Table 3 1 ANSI Standard Runtime Environment Macros amp Definitions 3 2 ANSI STANDARD FUNCTIONS Header Purpose math h Mathematics signal h Signal Handling stdarg h Variable Arguments ctype h Character Handling string h String Handling stdlib h Standard Library locale h Localization assert h Diagnostics set jump h Non Local Jumps stdio h Input Output Table 3 2 ANSI Standard Functions Note The stdio h file only contains the definition for EOF The C Runtime Library does not provide standard I O routines 3 Library Structure absolute value abs FUNCTION abs absolute value SYNOPSIS include lt stdlib h gt int abs int j DESCRIPTION The abs function returns the absolute value of its int input Note abs INT_MIN returns INT_MIN ERROR CONDITIONS e abs function does not return an error condition EXAMPLE include lt stdlib h gt int 1 i abs 5 i 5 SEE ALSO fabs labs acos arc cosine FUNCTION acos arc cosine SYNOPSIS include lt math h gt double acos double DESCRIPTION The acos function returns the arc cosine of x The input must be in the range 1 1 The output in radians is in the range 0 z The acos function returns a value that is accurate to 20 bits of the mantissa This accuracy correspond
26. or condition EXAMPLE include lt math h gt double y y atan 0 0 E y 0 0 SEE ALSO atan2 tan arc tangent of quotient atan2 FUNCTION atan2 arc tangent of quotient SYNOPSIS include lt math h gt double atan2 double x double y DESCRIPTION The atan2 function computes the arc tangent of the input value x divided by input value y The output in radians is in the range Ir 7 The atan2 function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 2 20 over its input range ERROR CONDITIONS The atan2 function returns a zero and sets errno to EDOM if x 0 and y lt gt 0 EXAMPLE include lt math h gt double A A atan2 0 0 0 5 A 0 0 SEE ALSO atan tan ceil ceiling FUNCTION ceil ceiling SYNOPSIS include lt math h gt double ceil double DESCRIPTION The ceil function returns the smallest integral value expressed as double that is not less than its input ERROR CONDITIONS The ceil function does not return an error condition EXAMPLE include lt math h gt double y y ceil 1 05 y 2 0 SEE ALSO floor cosine cos FUNCTION cos cosine SYNOPSIS include lt math h gt double cos double DESCRIPTION The cos function returns the cosine of the argument The input is interpreted as radians the output is in the range 1 1 The cos f
27. pes The compiler uses these prototypes to check that your program calls each function with the correct arguments 2 1 2 Built In Functions The C Runtime Library built in functions are a small set of functions that the compiler immediately recognizes and replaces with inline assembly code instead of a function call Typically inline assembly code is faster than an average library routine and it does not incur calling overhead For example strcpy a function used to oy one string into another space is recognized by the compiler whic subsequently replaces a call to the C Runtime Library version with an inline version The following routines are built in functions for the G21 compiler abs strcmp fabs strcpy labs strlen memcpy sqrt memcmp If you want to use the C Runtime Library functions of the same name compile with the fno builtin G21 command line switch 2 1 Using Library Functions 2 2 LIBRARY DIRECTORY The linker looks for the C Runtime Library libda a in the sub directory 21xx 1ib ofthe directory specified in the ADI DSP operating system environment variable For example in an MS DOS system with the value of ADI DSP setto c adi_dsp the linker looks for the C Runtime Library in the directory c adi_dsp 21xx lib 2 3 LIBRARY SOURCE CODE The distribution disks contain source code for the functions and macros in the C Runtime Library By default the installation p
28. py copy characters from one object to another SYNOPSIS include lt string h gt void memcpy void sl const void s2 size t n DESCRIPTION The memcpy function copies n characters from the object pointed to by s2 into the object pointed to by s1 The behavior of memcpy is undefined if the two objects overlap The memcpy function returns the address of s1 ERROR CONDITIONS e memcpy function does not return an error condition EXAMPLE include lt string h gt char a char b H l m un H result memcpy b a 3 b SRC L 35 memset set range of memory to a character SEE ALSO Strcpy strncpy FUNCTION memset set range of memory to a character SYNOPSIS include lt string h gt void memset void sl int c size_t n DESCRIPTION The memset function sets a range of memory to the input character c The first n characters of s1 aresetto c The memset function returns a pointer to s1 ERROR CONDITIONS The memset function does not return an error condition EXAMPLE include lt string h gt char stringl 50 memset stringl 0 50 set stringl to 0 SEE ALSO memcpy separate integral and fractional parts modf FUNCTION modf separate integral and fractional parts SYNOPSIS include lt math h gt double modf double double DESCRIPTION The modf function separates the first argument into integral and fractional portions The fractional portion is
29. r condition EXAMPLE include lt string h gt char stringl 50 strncpy stringl MOREFUN 4 MORE is copied into stringl stringl 4 0 must null terminate stringl SEE ALSO memcpy strcpy tangent tan FUNCTION tan tangent SYNOPSIS include lt math h gt double tan double DESCRIPTION The tan function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 220 over its input range ERROR CONDITIONS e tan function does not return an error condition EXAMPLE include lt math h gt double y y tan 3 14159 4 0 y 1 0 SEE ALSO atan atan2 tanh hyperbolic tangent FUNCTION tanh hyperbolic tangent SYNOPSIS include lt math h gt double tanh double DESCRIPTION The tanh function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 2 20 over its input range ERROR CONDITIONS e tanh function does not return an error condition EXAMPLE include lt math h gt double x y y tanh x SEE ALSO sinh cosh disable ADSP 21 XX timer timer_off FUNCTION timer_off disable ADSP 21xx timer SYNOPSIS include lt misc h gt unsigned int timer_off void DESCRIPTION This function is an Analog Devices extension to the ANSI standard The timer_off function disables the ADSP 21xx timer and returns the
30. returned and the integral ortion is stored in the object pointed to by The integral and ractional portions have the same sign as the input ERROR CONDITIONS The modf function does not return an error condition EXAMPLE include lt math h gt double y n y modf 12 345 an y 12 0 n 0 345 SEE ALSO frexp L 37 L 38 pow raise to a power FUNCTION pow raise to a power SYNOPSIS include lt math h gt double pow double double DESCRIPTION The pow function computes the value of the first argument raised to the power of the second argument The pow function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 2 20 over its input range ERROR CONDITIONS omain error occurs if the first argument is negative and the second argument cannot be represented as an integer If the first argument is zero the second argument is less than or equal to zero and the result cannot be represented EDOM is stored in errno EXAMPLE include lt math h gt double z z pow 4 0 2 0 z 16 0 SEE ALSO ldexp force a signal raise FUNCTION raise force a signal SYNOPSIS include lt signal h gt int raise int sig DESCRIPTION The raise function sends the signal sig to the executing program The raise function forces interrupts wherever possible and simulates an interrupt otherwise The sig argument
31. rogram copies the source code to a subdirectory of the directory where the runtime libraries are kept named 21xx lib src For example in an MS DOS system the source code for the library is found in the c adi_dsp 21xx lib src directory Each function is kept in a separate file If you do not intend to modify any of the C Runtime Library functions you can delete this directory and its contents to conserve disk space The source code is provided so you can customize any particular function for your own needs Customizing the library requires knowledge of both ADSP 2100 Family assembly language and the C Runtime environment For information on ADSP 2100 Family assembly language refer to the ADSP 2100 Family User s Manual For information on the C Runtime environment see the ADSP 2100 Family C Tools Manual Copy the source code to a file with a different filename before you make any modifications to the source code Use a new unique name for your modified function Note Analog Devices only supports the runtime library functions as provided Library Structure El 3 The C Runtime Library has several categories of functions and macros defined by the ANSI C standard plus extensions provided by Analog Devices 3 1 ANSI RUNTIME ENVIRONMENT MACROS amp DEFINITIONS The error handling standard definitions limits and floating point categories do not contain individual functions they consist of macros and type definiti
32. s how a signal received during program execution is handled It causes a single occurance of an interrupt to be responded to The sig argument must be one of the following values that are listed below in highest to lowest priority of interrupts Signal Value Meaning SIG_IGN Signal Ignore SIG_DFL Signal Default SIG_ERR Signal Error SIGINT3 Interrupt 3 lt ADSP 2100 Only gt SIGINT2 Interrupt 2 SIGINT1 Interrupt 1 SIGINTO Interrupt 0 SIGSPORTOXMIT Signal Sport 0 Transmit lt Not ADSP 2100 gt SIGSPORTORECV Signal Sport 0 Receive SIGTIMER Signal Timer SIGSPORTIXMIT Signal Sport 1 Transmit lt Not ADSP 2100 gt SIGSPORTIRECV Signal Sport 1 Receive lt Not ADSP 2100 gt SIGHIPWRITE Signal HIP Write lt ADSP 2111 ADSP 2150 ADSP 2171 Only gt SIGHIPREAD Signal HIP Read lt ADSP 2111 ADSP 2150 ADSP 2171 Only gt SIGPOWERDOWN Signal Power Down lt ADSP 2150 ADSP 2171 gt SIGCODECXMIT Signal Codec Transmit lt ADSP 2150 Only gt SIGCODECREC Signal Codec Record lt ADSP 2150 Only gt SIGSWI1 Signal Software Interupt 1 lt ADSP 2171 Only gt SIGSWIO Signal Software Interupt 0 lt ADSP 2171 Only gt signal define signal handling The signal function causes the receipt of the signal number func to be handled in one of the following ways func value action SIG_DFL The default action is taken SIG_IGN The signal is ignored Function address The function pointed to by func is executed The function pointed to by fun
33. s to a maximum relative error of 2 20 over its input range ERROR CONDITIONS The acos function indicates a domain error by setting errno to EDOM and returns a zero if the input is not in the range 1 1 EXAMPLE include lt math h gt double y y acos 0 0 y 0 2 SEE ALSO COS arc sine asin FUNCTION asin arc sine SYNOPSIS include lt math h gt double asin double DESCRIPTION Ihe asin function returns the arc sine of the argument The input must be in the range 1 1 The output in radians is in the range x 2 n 2 The asin function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 2 20 over its input range ERROR CONDITIONS The asin function indicates a domain error set errno to EDOM and returns a zero if the input is not in the range 1 1 EXAMPLE include lt math h gt double y y asin 1 0 y 0 2 SEE ALSO sin L 3 atan arc tangent FUNCTION atan arc tangent SYNOPSIS include lt math h gt double atan double DESCRIPTION The atan function returns the arc tangent of the argument The output in radians is in the range x 2 7 2 The atan function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 220 over its input range ze CONDITIONS The atan function does not return an err
34. separated by acomma and enclosed in two square brackets two parentheses or one of each A square bracket indicates that the endpoint is included in the set of numbers a parenthesis indicates that the endpoint is not included Introduction 1 2 2 Reference Format Each function in the library is listed in the following format Description Explanation FUNCTION Purpose of the function foof does nothing SYNOPSIS include lt fnord h gt Required header file and void foof float x functional prototype DESCRIPTION Function specification The foof function ERROR CONDITIONS How the function indicates an error Errors returned by the foof EXAMPLE Typical function usage include lt fnord h gt foof 0 0 SEE ALSO Related functions foo2 foo3 Using Library Functions EI 2 2 1 CALLING FUNCTIONS To use a C library function call the function by name and give the appropriate arguments The necessary arguments for each function are specified in the Library Reference section of this volume You can use the librarian 1ib21 documented in the ADSP 2100 Family Assembler Manual to build libraries of your own functions 2 1 1 Header Files If your program calls a library function you must include the header file containing the function with the include C preprocessor directive For the header file to include see the Synopsis section of the library function you call Header files contain function prototy
35. sn een L 55 enable ADSP 21 XX timer s a L 56 initialize ADSP 21XX MEN uegnet L 57 get next argument in variable list L 58 reset variable list pointer sn neue ue nn L 59 set variable list pointer vasene deus L 60 ANSI Standard Runtime Environment Macros amp Definitions 3 1 ANSI Standard Functions usa anna nn 3 1 C Runtime Library Header Files 4 1 vii Contents viii Introduction EI 1 1 1 OVERVIEW The C Runtime Library Manual documents a set of C callable functions written in ADSP 2100 Family assembly language Programs written in C depend on library functions to perform basic operations not provided by the language These functions include memory allocation signal processing and mathematics functions Use of the library simplifies the software development process This document describes the current release of the runtime library Future releases may include more functions The object files of the library functions may be freely used in systems based on ADSP 2100 Family processors The algorithms used to implement many of the mathematic functions are taken from the following reference Cody and Waite Software Manual For The Elementary Functions Prentice Hall 1980 See the current ADSP 2100 Family Development Software Tools release note for function benchmarks 1 2 DOCUMENTATION 1 2 1 Notation Conventions An interval of numbers is indicated by the minimum and maximum
36. teger absolute value SYNOPSIS include lt stdlib h gt long int labs long int j DESCRIPTION The 1 labs function returns the absolute value of its integer input ERROR CONDITIONS The labs function does not return an error condition EXAMPLE include lt stdlib h gt long int j j labs 285128 j 285128 SEE ALSO abs fabs multiply by power of 2 Idexp FUNCTION Idexp multiply by power of 2 SYNOPSIS include lt math h gt double ldexp double int DESCRIPTION The 1dexp function returns the value of the floating point input multiplied by 2 It adds the value of n to the exponent of x ERROR CONDITIONS If the result overflows ldexp returns HUGE_VAL with the proper sign and sets errno to ERANGE If the result underflows a zero is returned EXAMPLE include lt math h gt double y y ldexp 0 5 2 y 2 0 SEE ALSO exp pow L 31 log natural logarithm FUNCTION log natural logarithm SYNOPSIS include lt math h gt double log double DESERE DN log function produces the appropriate precision natural base e en of its input The log function returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 220 over its input range PRROR CONDITIONS The log function returns a zero and sets errno to EDOM ifthe input value is negative EXAMPLE include lt math h gt double y y
37. ter ERROR CONDITIONS e fir function does not return an error condition EXAMPLE include lt filters h gt int y int pm coeffs 10 coeffs array must be initialized and in PM memory int state ll int iy for i 0 i lt 11 i state i 0 initialize state array y fir 0x1234 coeffs state 10 y holds the filtered output SEE ALSO iir floor floor FUNCTION floor floor SYNOPSIS include lt math h gt double floor double DESCRIPTION The floor function produces the largest integral value that is not greater than its input ERROR CONDITIONS The floor function does not return an error condition EXAMPLE include lt math h gt double y y floor 1 25 y 1 0 y floor 1 25 y 2 0 SEE ALSO ceil fmod floating point modulus FUNCTION fmod floating point modulus SYNOPSIS include lt math h gt double fmod double double DESCRIPTION The fmod function computes the floating point remainder that results from dividing the first argument into the second argument This value is less than the second argument and has the same sign as the first argument If the second argument is equal to zero fmod returns a Zero u CONDITIONS The fmod function does not return an error condition EXAMPLE include lt math h gt double y y fmod 5 0 2 0 y 1 0 SEE ALSO modf separate fraction and exponent
38. ter L 15 NOU ude L 17 floating point modulus l un sn rs L 18 separate fraction and exponent a L 19 N point inverse complex input fast Fourier transform IFFT L 20 infinite impulse response IIR filter L 23 define interrupt handling ee L 26 detect alphabetic character a L 28 detect decimal digitoa masse een L 29 long integer absolute value a L 30 multiply by power EEE L 31 natural logarithm n a ea taba ted nn L 32 base 10 logarithm een L 33 compare ODJeCtS Rise A tt An A EST L 34 copy characters from one object to another L 35 set range of memory to a character L 36 separate integral and fractional parts L 37 BEE BA POWER ee L 38 6 SK 0 ee ee L 39 define signal handling usa L 41 SNE ae L 43 hyperbolic sine nein scher L 44 SOURS 010 een L 45 concatenate strings EE ce ne tn L 46 COMPAS SINGS ne tano L 47 copy from one string to another L 48 SINGEL L 49 concatenate characters from one string to another L 50 compare characters in strings see L 51 strncpy tan tanh timer_off timer_on timer_set va_arg va_end va_start TABLES Table 3 1 Table 3 2 Table 4 1 Contents copy characters from one string to another L 52 tangente a re eek L 53 hyperbolic tangent Lane L 54 disable ADSP 21XX timer
39. unction returns a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 220 over its input range Although the cos function accepts input over the entire floating point range the accuracy of the result decreases significantly for a large input greater than 712 2 ERROR CONDITIONS The cos function does not return an error condition EXAMPLE include lt math h gt double y y cos 3 14159 y 1 0 SEE ALSO acos L 8 cosh hyperbolic cosine FUNCTION cosh hyperbolic cosine SYNOPSIS include lt math h gt double cosh double DESCRIPTION The cosh function returns the hyperbolic cosine of its argument and a value that is accurate to 20 bits of the mantissa This accuracy corresponds to a maximum relative error of 2 20 over its input range ERROR CONDITIONS The cosh function returns HUGE_VAL andsets errno to ERANGE if the input exceeds 212 EXAMPLE include lt math h gt double x y y cosh x SEE ALSO sinh remove the mean demean buffer of a data buffer FUNCTION demean_buffer remove the mean of a data buffer SYNOPSIS include lt filters h gt int demean buffer int input buffer int old mean int LENGTH DESCRIPTION The demean_buffer routine removes a DC bias from input signals and the mean from a buffer of data It can also execute a notch filter on the input based on an adaptive filter See Adaptive Signa

Download Pdf Manuals

image

Related Search

Related Contents

レンタル約款のご確認  e - CRISTOR  Corsair MM200  CP-Venise-PAC2015-FRAC  Samsung SGH-J150 Керівництво користувача  Tenovis Fax 367 - Lipinski Telekom  Características y Beneficios  QMark WPC1500 Panel Heater Owner`s Manual  EVGA nForce 650i Ultra 775  Model E112/F112 OWNER`S MANUAL  

Copyright © All rights reserved.
Failed to retrieve file