Home

ANALOG DEVICES VisualDSP 5.0 Run-Time Library Manual for SHARC Processors (Revision 1.2 March 2009)

image

Contents

1. SIG Value Definition Default setting for programmable peripheral interrupts SIG TICDI Illegal input condition detected SIG SOVF Status stack or Loop stack overflow or PC stack full SIG TMZ0 Timer 0 high priority option SIG BKP Hardware breakpoint SIG IRO2 Interrupt 2 SIG IRO1 Interrupt 1 SIG IROO Interrupt 0 SIG PO Peripheral interrupt 0 DAI High priority SIG P1 Peripheral interrupt 1 SPI transmit or receive high priority option SIG P2 Peripheral interrupt 2 General purpose IOP timer 0 SIG P3 Peripheral interrupt 3 SPORT 1 SIG P4 Peripheral interrupt 4 SPORT 3 SIG P5 Peripheral interrupt 5 SPORT 5 SIG P6 Peripheral interrupt 6 SPORT 0 SIG P7 Peripheral interrupt 7 SPORT 2 1 106 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library Table 1 33 ADSP 2136x Processor Signals Contd SIG Value Definition Default setting for programmable peripheral interrupts SIG_P8 Peripheral interrupt 8 SPORT 4 SIG_P9 Peripheral interrupt 9 Parallel port SIG_P10 Peripheral interrupt 10 General purpose IOP timer 1 SIG_P12 Peripheral interrupt 12 DAI low priority SIG_P13 Peripheral interrupt 13 PWM SIG_P15 Peripheral interrupt 15 DTCP SIG_P17 Peripheral interrupt 17 General purpose IOP timer 2 SIG_P18 Peripheral int
2. SIG_TMZ Timer 0 low priority option SIG FIX Fixed point overflow SIG FLTO Floating point overflow exception SIG FLTU Floating point underflow exception SIG FLTI Floating point invalid exception SIG USRO User software interrupt 0 SIG USRI User software interrupt 1 SIG USR2 User software interrupt 2 SIG USR3 User software interrupt 3 SIG USR4 User software interrupt 4 SIG USR5 User software interrupt 5 Table 1 30 ADSP 2106x Processor Signals SIG Value Definition SIG SOVF Status stack or Loop stack overflow or PC stack full SIG TMZ0 Timer 0 high priority option SIG VIRPTI Vector Interrupt SIG IRO2 Interrupt 2 SIG IROI1 Interrupt 1 SIG IROO Interrupt 0 SIG SPROI DMA Channel 0 SPORTO Receive SIG SPRI1I DMA Channel 1 SPORTI Receive or Link Buffer 0 SIG_SPTOI DMA Channel 2 SPORTO Transmit SIG_SPT1I DMA Channel 3 SPORT 1 Transmit or Link Buffer 1 ISIG_LP2I DMA Channel 4 Link Buffer 2 VisualDSP 5 0 Run Time Library Manual 1 101 for SHARC Processors C Run Time Library Reference Table 1 30 ADSP 2106x Processor Signals Contd SIG Value Definition SIG_LP3I DMA Channel 5 Link Buffer 3 SIG_EPOI DMA Channel 6 Ext Port Buffer 0 or Link Buffer 4 SIG EPII DMA Channel 7 Ext Port Buffer 1 or Link Buffer 5 sIG_EP2I DMA Channel 8 Ext Port Bu
3. VisualDSP 5 0 Run Time Library Manual 2 161 for SHARC Processors DSP Run Time Library Reference where N window size w kaiser window n 0 1 2 N 1 a N 1 2 Ip B represents the zero order modified Bessel function of the first kind Domain a gt 0 N gt 0 b gt 0 0 Error Conditions The gen_kaiser function does not return an error condition See Also gen_bartlett gen_blackman gen_gaussian gen_hamming gen_hanning gen_harris gen_rectangular gen_triangle gen_vonhann 2 162 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library gen rectangular Generate rectangular window Synopsis include lt window h gt void gen rectangular float dm wl int a int N Description The gen rectangular function generates a vector containing the rectan gular window The length of the required window is specified by the parameter N and the stride parameter a is used to space the window values within the output vector w The length of the output vector should there fore be N a Algorithm win 1 where n 0 1 2 N 1 Domain a gt 0 N gt 0 Error Conditions The gen_rectangular function does not return an error condition VisualDSP 5 0 Run Time Library Manual 2 163 for SHARC Processors DSP Run Time Library Reference See Also gen bartlett gen blackman gen gaussian gen hamming gen hanning gen harris gen kaiser gen triangle
4. Flag Macro Value Mode Macro Value READ_FLAGO 0 FLAG_IN_LO_TO_HI 0 READ FLAGI 1 FLAG IN HI TO LOW 1 READ FLAG2 2 FLAG IN HI 2 READ FLAG3 3 FLAG IN LOW 3 READ FLAG3 3 FLAG IN TRANSITION 4 READ FLAG3 3 RETURN FLAG STATE 5 This function assumes that the flag direction in the MODE2 register is already set as an input the default state at reset VisualDSP 5 0 Run Time Library Manual 2 221 for SHARC Processors DSP Run Time Library Reference Error Conditions The poll flag in function returns a negative value for an invalid flag or transition mode Example include lt processor_include h gt poll_flag_in 0 3 return zero after transition has occurred See Also interrupt set_flag 2 222 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library rfft Real radix 2 Fast Fourier Transform Synopsis include lt filter h gt complex float rfft float dm inputl float dm tempL complex float dm outputl const complex float pm twiddlelJ int twiddle stride int n Description The rfft function transforms the time domain real input signal sequence to the frequency domain by using the radix 2 Fast Fourier Transform FFT The size of the input array input and the temporary working buffer temp must be at least n where n represents the number of points in the FFT n must be a power of 2 and no smaller than 16 If the input data
5. WISUAUDSP 5 0 Run Time Library Manual for SHARC Processors Revision 1 2 March 2009 Part Number 82 000420 09 Analog Devices Inc One Technology Way gt ANALOG Norwood Mass 02062 9106 DEVICES Copyright Information 2009 Analog Devices Inc ALL RIGHTS RESERVED This document may not be reproduced in any form without prior express written consent from Analog Devices Inc Printed in the USA Disclaimer Analog Devices Inc reserves the right to change this product 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 impli cation or otherwise under the patent rights of Analog Devices Inc Trademark and Service Mark Notice The Analog Devices logo the CROSSCORE logo VisualDSP SHARC and EZ KIT Lite are registered trademarks of Analog Devices Inc All other brand and product names are trademarks or service marks of their respective owners CONTENTS PREFACE Purposeof This Manual oem makanmakan xxxi an Na Naa SN ANN aa Sa PA Den BN ees xxxi Mamaa OAOE oren xxxii Shiste New mn This Minil bbm emng xxxii Technical or Customer SUpport sb mk xxxiii Supported DO el aneka R xxxiii Produet Informan Mn Na e AN XXXIV Anale Dena Veb SIE erene XXXIV VisnalDSP
6. fscanf fp aeiou string See Also scanf sscanf VisualDSP 5 0 Run Time Library Manual 1 161 for SHARC Processors C Run Time Library Reference fseek Reposition a file position indicator in a stream Synopsis include lt stdio h gt int fseek FILE stream long offset int whence Description The fseek function sets the file position indicator for the stream pointed to by stream The position within the file is calculated by adding the off set to a position dependent on the value of whence The valid values and effects for whence are as follows whence Effect SEEK_SET Set the position indicator to be equal to of fset bytes from the begin ning of stream SEEK_CUR Set the new position indicator to current position indicator for stream plus offset SEEK_END Set the position indicator to EOF plus offset Using fseek to position a text stream is only valid if either offset is zero or if whence is SEEK_SET and offset is a value that was previously returned by ftell Positioning within a file that has been opened as a text stream is only supported by the libraries that Analog Devices supply if the lines within the file are terminated by the character sequence r n A successful call to fseek will clear the EOF indicator for stream and undoes any effects of ungetc on stream If the stream has been opened as a update stream then the next I O operation may be either a read
7. 2 42 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library where k f0 1 lags 1 a is the mean value of input vector a Error Conditions The autocoherence functions do not return an error condition Example include lt stats h gt define SAMPLES 1024 define LAGS 16 double excitation SAMPLES double response LAGS int lags LAGS autocoh response excitation SAMPLES lags See Also autocorr crosscoh crosscorr VisualDSP 5 0 Run Time Library Manual 2 43 for SHARC Processors DSP Run Time Library Reference autocom Autocorrelation Synopsis include lt stats h gt float autocorrf float dm out const float dm int int samples int lags double autocorr double dm out const double dm in int samples int lags long double autocorrd long double dm out const long double dm in int samples int lags Description The autocorrelation functions perform an autocorrelation of a signal Autocorrelation is the cross correlation of a signal with a copy of itself It provides information about the time variation of the signal The signal to be autocorrelated is given by the in input array The number of samples of the autocorrelation sequence to be produced is given by lags The length of the input sequence is given by samples The functions return a pointer to the out output data array of length Jags Autocorrelation is us
8. long double scalar int rows int cols Description The matssub functions subtract a scalar from each element of the input matrix a and return the result in the matrix output The dimen sions of these matrices are a rows cols and outputLrows cols The functions return a pointer to the output matrix Error Conditions The matssub functions do not return an error condition Example include lt matrix h gt dtdefine ROWS 4 dtdefine COLS 8 double inputLROWSJLCOLS a_p double amp input VisualDSP 5 0 Run Time Library Manual 2 207 for SHARC Processors DSP Run Time Library Reference double resultIROWSJICOLSJ res p double amp result double x matssub res p ap x ROWS COLS See Also cmatssub matmsub matsadd matsmlt For the ADSP 21xxx SIMD processors the matssubf function and matssub if doubles are the same size as floats uses SIMD by default Refer to Implications of Using SIMD Mode on page 2 23 for more information 2 208 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library mean Mean Synopsis include lt stats h gt float meanf const float inl int length double mean const double inL int length long double meand const long double in int length Description The mean functions return the mean of the input array inl The length of the input array is length Error Conditions The mean funct
9. Description The vfprintf function formats data according to the argument format and then writes the output to the stream stream The argument format contains a set of conversion specifiers directives and ordinary characters that are used to control how the data is formatted Refer to fprintf on page 1 143 for a description of the valid format specifiers The vfprintf function behaves in the same manner as fprintf with the exception that instead of being a function which takes a variable number or arguments it is called with an argument list ap of type va_list as defined in stdarg h If the vfprintf function is successful it will return the number of charac ters output Error Conditions The vfprintf function returns a negative value if unsuccessful Example include lt stdio h gt include lt stdarg h gt void write_name_to_file FILE fp char name_template VisualDSP 5 0 Run Time Library Manual 1 333 for SHARC Processors C Run Time Library Reference va list p_vargs int ret return value from vfprintf va_start p_vargs name_template ret vfprintf fp name_template p_vargs va_end p_vargs if ret lt 0 printf vfprintf failed n See Also fprintf va_start va_end 1 334 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library vprintf Print formatted output of a variable argument list to stdout Synopsis include lt stdio h gt in
10. The first character that does not fit either form of number stops the scan If endptr is not NULL a pointer to the character that stopped the scan is stored at the location pointed to by endptr If no conversion can be per formed the value of nptr is stored at the location pointed to by endptr Error Conditions The strtod function returns a zero if no conversion can be made and a pointer to the invalid string is stored in the object pointed to by endptr If the correct value results in an overflow a positive or negative as appropri ate HUGE_VAL is returned If the correct value results in an underflow zero is returned The ERANGE value is stored in errno in the case of either an overflow or underflow Example include lt stdlib h gt char rem double dd dd strtod 2345 5E4 abc amp rem dd 2 3455E 7 rem abc VisualDSP 5 0 Run Time Library Manual 1 307 for SHARC Processors C Run Time Library Reference dd strtod 0x1 800p 9 123 amp rem dd 768 0 rem 123 See Also atof strtol strtoul 1 308 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library strtok Convert string to tokens Synopsis include lt string h gt char strtok char s1 const char s2 Description The strtok function returns successive tokens from the string s1 where each token is delimited by characters from s2 A call to strtok with s1 not
11. 1 54 ie DAE pitt E E E dea 1 56 vi VisualDSP 5 0 Run Time Library Manual for SHARC Processors CONTENTS Extending I O Support To New Devices arena 1 57 DesEntiy SEE sonerion eee 1 57 Regering Now Dargi kam 1 62 Preker rerne DNES an eee ania 1 63 na Na DA e 1 65 Remove and Rename Functions kam na 1 66 Default Device Driver Interface bosen mlm 1 66 Data Packing tor Primitive DO mama abonenamasakonas 1 67 Dara Structmre for Primitive VO oecieranenenaricrna 1 68 Documented Library Functions ansietas ambang 1 71 C Run Dime Library Reference mek asa 1 76 O sn aka bak me aan 1 77 Aa Mn aa Pan San Ann AN Tn DAA PA An andes 1 78 en OIE ane EE Gn Ann T E mney on aa ene ne Cee 1 79 MA La SNN an PEN NA MAN On PA PENATAAN ANT 1 80 EIU ena aman ene NN ES 1 82 NCU ebi mak nama mam aa mama ia 1 83 SR ena RA 1 84 MOI IAIN ANN NI 1 85 RSS memanas ak kak emak mem kebal aman sangan 1 86 Aa KN aa An aren alana Ann 1 89 ET MEA MA NN EDS EPA ANN MOULD COT EME CETTE ACE ME NN NA 1 90 ROE Ka E PA E NS T PN AT 1 91 WES E E PN ng 1 94 VisualDSP 5 0 Run Time Library Manual vii for SHARC Processors CONTENTS Be beam aman ere 1 95 Ge sone 1 97 l an ORC AN UEP RENE ESTE RP ERO ATPL RAPP NN eT Se OA 1 99 clear I oe ee eee 1 100 CMI i iia pti ied kt mk Bilah 1 111 CMD cain PE E AN an 1 113 ON ea ba aa Bea aa 1 114 ONE wa anyammnlakamanjon aminn 1 116 NN NN ene nO One Mn en OLE Ree Un AE ADA APE PA NAN PD 1 117 counte rusa 1 118 UNO iman o
12. C C Run Time Library Macros for minimum width integer constants include INT8_C x INT16_C x INT32 C x UINT8 C x UINT16_C x and UINT32_C x Macros for greatest width integer constants include INTMAX_C x and UINTMAX_C x stdio h The stdio h header file defines a set of functions macros and data types for performing input and output Applications that use the facilities of this header file should link with the I O library 1ibio d1b in the same way as linking with the C run time library see Linking Library Functions on page 1 4 The library is thread safe but it is not interrupt safe and should not therefore be called either directly or indirectly from an interrupt ser vice routine The compiler uses definitions within the header file to select an appropri ate set of functions that correspond to the currently selected size of type double either 32 bits or 64 bits Any source file that uses the facilities of stdio h must therefore include the header file Failure to include the header file results in a linker failure as the compiler must see a correct function prototype in order to generate the correct calling sequence The implementation of the stdio h routines is based on a simple interface with a device driver that provides a set of low level primitives for open close read write and seek operations By default these operations are provided by the VisualDSP simulator and EZ KIT Lite systems and this mec
13. Contains additional library functions sup plied by Analog Devices that provide services commonly required by DSP applications e I O library Supports a subset of the C standard s I O functionality In general several versions of the C C run time library are supplied in binary form for example variants are available for different SHARC architectures and are listed in Table 1 1 Table 1 2 Table 1 3 and Table 1 4 Some versions of these binary files are also built for running in a multi threaded environment these binaries have mt in their filename In addition to regular run time libraries VisualDSP 5 0 also has libiox lite dIb libraries which provide smaller versions of Lib10 the I O run time support library with more limited functionality These smaller Lib10 libraries can be used by specifying the switch flags link MD__LIBIO_LITE on the build command line 1 4 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library Table 1 1 contains a list of the run time libraries and start up files that have been built for the ADSP 21020 and ADSP 2106x processors and are installed in the subdirectory 21k 1ib Table 1 1 C C Files and Libraries for ADSP 210xx Processors exception handling support ibcppehmt dib Description Library Name Comments C run time library ibc dib ibc020 d1b ADSP 21020 processor only ibemt d1b C run time library ibcpp dib ibcppmt dib C r
14. For more information on creating multiple run time heaps see Chapter 1 of the VisualDSP 5 0 Compiler Manual section Using Multiple Heaps Error Conditions The heap_malloc function returns the null pointer if unable to allocate the requested memory Example include lt stdlib h gt include lt stdio h gt int main 1 186 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library char buf int index Obtain the heap index for seg_hp2 index heap_lookup_name seg_hp2 if index lt 0 printf Heap with name seg_hp2 not found n return 1 Allocate memory for 128 characters from seg_hp2 buf char heap_malloc index 128 if buf 0 printf Allocated space from 4pin buf free buf free can be used to release the memory else printf Unable to allocate from seg_hp2 n return 0 See Also calloc free heap calloc heap free heap lookup name heap realloc malloc realloc set alloc type VisualDSP 5 0 Run Time Library Manual 1 187 for SHARC Processors C Run Time Library Reference heap realloc Change memory allocation from a heap Synopsis include lt stdlib h gt void heap_realloc int heap index void ptr size_t size Description The heap_realloc function is an Analog Devices extension to the ANSI standard The heap_realloc function changes the size of a previously allocated block of memory
15. Maximum int max int a int b ong Imax long a long b Minimum int min int a int b ong Imin long a long b Multiple void heap_calloc int heap_index size_t nelem size_t size heaps for void heap_free int heap_index void ptr dynamic void heap_malloc int heap_index size_t size memory allo void heap_realloc int heap index void ptr size_t size cation int set_alloc_type char heap name int heap install void base size_t size int userid int pmdm int heap_lookup_name char userid int heap_switch int heapid A number of functions including abs avg max min and clip are imple mented via intrinsics provided the header file has been ffinclude d that map to single cycle machine instructions If the header file is not included the library implementation is used instead at a considerable loss in efficiency For a list of library functions that use this header see Table 1 26 on page 1 74 string h The string h header file contains string handling functions including strcpy and memcpy 1 32 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library For a list of library functions that use this header see Table 1 27 on page 1 75 time h The time h header file provides functions data types and a macro for expressing and manipulating date and time information The header file defines two fundamental data types one of w
16. long double vecvaddd const long double dm al const long double dm b long double dm output int samples Description The vecvadd functions compute the sum of each of the elements of the vectors a and b and store the result in the output vector All three vectors are samples in size The functions return a pointer to the output vector Error Conditions The vecvadd functions do not return an error condition Example include lt vector h gt define N 100 double input IINJ 2 276 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library double input 2INJ result N vecvadd input 1 input 2 result N See Also cvecvadd vecsadd vecvmit vecvsub For the ADSP 21xxx SIMD processors the vecvaddf function and vecvadd if doubles are the same size as floats uses SIMD by default Refer to Implications of Using SIMD Mode on page 2 23 for more information VisualDSP 5 0 Run Time Library Manual 2 277 for SHARC Processors DSP Run Time Library Reference vecvmit Vector vector multiplication Synopsis include lt vector h gt float vecvmltf const float dm aL const float dm bLJ float dm output int samples double vecvmlt const double dm aL const double dm b double dm outputL int samples long double vecvmltd const long double dm al const long double dm b long double dm output int samples Description The vecvmlt
17. tm_time tm_year 2000 1900 tm_time tm_mday 1 if mktime amp tm_time 1 tm_time tm_wday 7 printf 24d started on a 4s n 900 tm_time tm_year wdayLtm_time tm_wday 1 238 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library See Also gmtime localtime time VisualDSP 5 0 Run Time Library Manual 1 239 for SHARC Processors C Run Time Library Reference modf Separate integral and fractional parts Synopsis include lt math h gt float modff float x float intptr double modf double x double intptr long double modfd long double x long double intptr Description The modf functions separate the first argument into integral and frac tional portions The fractional portion is returned and the integral portion is stored in the object pointed to by intptr The integral and fractional portions have the same sign as the input Error Conditions The modf functions do not return error conditions Example include lt math h gt double y n float m p y modf 12 345 amp n y 0 345 n 12 0 m modff 11 75 amp p m 0 75 p 11 0 See Also frexp 1 240 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library perror Print an error message on standard error stream Synopsis include lt stdio h gt void perror const char s Description The per
18. INDEX standard header files assert h 1 20 ctype h 1 21 cycle count h 1 21 cycles h 1 22 device h 1 22 device int h 1 22 errno h 1 22 float h 1 23 iso646 h 1 24 limits h 1 24 locale h 1 24 math h 1 25 setjmp h 1 26 signal h 1 26 stdarg h 1 27 stdbool h 1 27 stddef h 1 27 stdio h 1 29 stdlib h 1 31 string h 1 32 time h 1 33 VisualDSP 5 0 Run Time Library Manual I 17 for SHARC Processors INDEX standard library functions abort 1 77 abs 1 78 acos 1 79 atexit 1 85 atoi 1 89 atol 1 90 avg 1 94 bsearch 1 95 calloc 1 97 clip 1 113 count ones 1 118 div 1 123 exit 1 125 free 1 153 getenv 1 172 heap calloc 1 177 heap free 1 179 heap install 1 181 heap lookup name 1 184 heap malloc 1 186 heap realloc 1 188 heap switch 1 191 labs 1 211 lavg 1 212 Iclip 1 213 Icount_ones 1 214 Idiv 1 216 Imax 1 218 Imin 1 219 malloc 1 229 max 1 230 min 1 236 qsort 1 249 rand 1 253 realloc 1 256 srand 1 284 strtol 1 311 strtoul 1 316 system 1 320 standard math functions 2 14 fmax 2 144 fmin 2 145 START_CYCLE_COUNT macro 1 47 statistics functions 2 18 stats h header file 2 18 stdarg h header file 1 27 1 71 2 25 stddef h header file 1 27 stderrfd field 1 62 stdexcept header file 1 41 stdinfd field 1 62 stdint h header file 1 27 stdio h header file 1 29 1 56 1 71 2 25 stdlib h header file 1 31 1 71 2 25 stdoutfd field 1
19. else biguad vec input output coeffs NSAMPLES NSECTIONS endif See Also fir ir DSP Run Time Library VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library Reference Note that N the number of biquad sections First Section Second Section sample coeffs 2 coeffs 7 coeffs 4 coeffs 9 coeffs 3 coeffs 0 coeffs 5 coeffs 8 N 1th section nth section K 5 N 2 K 5 N 1 coeffs K 2 coeffs K 2 coeffs K 4 coeffs K 4 coeffs K 3 coeffs IKI coeffs K 3 coeffs K Figure 2 1 Biquad Sections 2 52 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library cabs Complex absolute value Synopsis include lt complex h gt float cabsf complex float z double cabs complex double z long double cabsd complex long double z Description The cabs functions return the floating point absolute value of their com plex input The absolute value of a complex number is evaluated with the following formula y Ret2 Ime Error Conditions The cabs functions do not return an error condition Example include lt complex h gt complex_float cnum float answer cnum re 12 0 SaO cnum im VisualDSP 5 0 Run Time Library Manual 2 53 for SHARC Processors DSP Run Time Library Reference answer cabsf cnum answer 13 0 See Also fabs labs 2
20. include lt stdlib h gt int abs int j Description The abs function returns the absolute value of its integer argument Note abs INT MIN returns INT MIN Error Conditions The abs function does not return an error condition Example include lt stdlib h gt int i i abs 5 je 5 See Also fabs labs 1 78 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library acos Arc cosine Synopsis include lt math h gt float acosf float x double acos double x long double acosd long double x Description The arc cosine functions return the arc cosine of x The input must be in the range 1 1 The output in radians is in the range 0 7 Error Conditions The arc cosine functions indicate a domain error set errno to EDOM and return a zero if the input is not in the range 1 1 Example include lt math h gt double x float y x acos 0 0 ex TIL ef acosf 0 0 y 1 2 ta ll See Also COS VisualDSP 5 0 Run Time Library Manual 1 79 for SHARC Processors C Run Time Library Reference asctime convert broken down time into a string Synopsis include lt time h gt char asctime const struct tm t Description The asctime function converts a broken down time as generated by the functions gmtime and localtime into an ASCII string that will contain the date and time in the form DDD MMM dd hh mm ss YYYY
21. make filename char name int id char filename template s d dat char filename NULL int len 0 intors return value from snprintf do r snprintf filename len filename template name id fF r lt 0 formatting error abort if r lt len was complete string written return filename return with success Filename realloc filename len r 1 while filename NULL abort See Also fprintf sprintf vsnprintf 1 280 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library sprintf Format data into a character array Synopsis include lt stdio h gt int sprintf char str const char format args Description The sprintf function formats data according to the argument format and then writes the output to the array str The argument format con tains a set of conversion specifiers directives and ordinary characters that are used to control how the data is formatted Refer to fprintf on page 1 143 for a description of the valid format specifiers In all respects other than writing to an array rather than a stream the behavior of sprintf is similar to that of fprintf If the sprintf function is successful it will return the number of charac ters written in the array not counting the terminating NULL character Error Conditions The sprintf function returns a negative value if a formatting error oc
22. Cross correlation is used in signal processing applications such as speech analysis Algorithm The following equation is the basis of the algorithm VisualDSP 5 0 Run Time Library Manual 2 103 for SHARC Processors DSP Run Time Library Reference 1 n k 1 od ps ao big j 0 where k 0 1 lags 1 a x b y n samples Error Conditions The cross correlation functions do not return an error condition Example include lt stats h gt define SAMPLES 1024 define LAGS 16 double excitation SAMPLESJ yISAMPLESJ double response LAGS int lags LAGS crosscorr response excitation y SAMPLES lags 2 104 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library See Also autocoh autocorr crosscoh For the ADSP 21xxx SIMD processors the crosscorrf function and crosscorr if doubles are the same size as floats uses SIMD refer to Implications of Using SIMD Mode on page 2 23 for more information VisualDSP 5 0 Run Time Library Manual 2 105 for SHARC Processors DSP Run Time Library Reference csub Complex subtraction Synopsis include lt complex h gt complex float csubf complex float a complex float b complex double csub complex double a complex double b complex long double csubd complex long double a complex long double b Description The csub functions subtract the two complex values a and b and return the result
23. Online Documentation anemia XXXV Technical Librar CD resa XXXV pee eet Conventions sem mmm am ma naa xxxvi C C RUN TIME LIBRARY Cand C Rum Time Libraries Guide sms aan mann 1 2 Calling Tab Fonero soseen N 1 3 Linking Library Fonctions ta tm 1 4 Lori PON s man ee aa aa 1 13 Exceptions to the Attribute Conventions sentana 1 15 VisualDSP 5 0 Run Time Library Manual for SHARC Processors ill CONTENTS Mapping Objects to FLASH Memory Using Attributes 1 18 Working With Library Header Files sisa 1 18 e A E E E A EAE EET E T 1 20 E A AEE ERE E ee 1 20 PAN E E I E T I TN TN 1 21 AN SM eeen 1 21 PIN ee em mm aka aa aka 1 22 OBB EA EA sma mna amami 1 22 devoe Beban an NN 1 22 a enn eRe E NN ANN PA AA ANA RAN DA DAN TEA 1 22 DOO samba bala 1 23 Me mes mma akan 1 24 Aa Ba Pan Pan SN Ann AN PA Pa SN SEA ri 1 24 locala orsi akn oma aa Maa 1 24 Me EN An E EAE 1 25 BN PA ii SARAN NE 1 26 Na Na AN NA na 1 26 Pa en E ain 1 27 Ma soto area eee eee 1 27 BO NE Io massa memasak uan 1 27 PAN ebi E E 1 27 ab ab 1 29 MO A menekan Dania 1 31 OE eh bkan amankan bak 1 32 iv VisualDSP 5 0 Run Time Library Manual for SHARC Processors CONTENTS MIE sgm ama emban 1 33 Calling Library Functions from an ISR sesuai 1 34 Using the Libraries in a Multi Threaded Environment 1 35 Using Compiler Built In C Library Functions 1 36 Abridged Kes Libtaty Support sebel hmmm 1 38 Embedded C Library Header File
24. Print formatted output Synopsis include lt stdio h gt int fprintf FILE stream const char format args Description The fprintf function places output on the named output stream The string pointed to by format specifies how the arguments are converted for output The format string can contain zero or more conversion specifications each beginning with the character The conversion specification itself follows the character and consists of one or more of the following sequence e Flag optional characters that modifies the meaning of the conversion e Width optional numeric value or that specifies the minimum field width e Precision optional numeric value that gives the minimum num ber of digits to appear e Length optional modifier that specifies the size of the argument e Type character that specifies the type of conversion to be applied The flag characters can be in any order and are optional The valid flags are described in the following table VisualDSP 5 0 Run Time Library Manual 1 143 for SHARC Processors C Run Time Library Reference Flag Field 7 Left justify the result within the field The result is right justified by default Always begin a signed conversion with a plus or minus sign By default only negative values will start with a sign space Prefix a space to the result if the first character is not a sign and the flag has not al
25. The delay line has the size num coeffs 1 Before the first call all ele ments must be set to zero The first element in the delay line holds the read write pointer being used by the function to mark the next location in the delay line to write to The pointer should not be modified outside this function It is needed to support the restart facility whereby the function can be called repeatedly carrying over previous input samples using the delay line The fir_decima function returns the address of the output array The library function uses the architecture s dual data move instruc tion to provide simultaneous access to the filter coefficients in PM data memory and the delay line When running on an ADSP 21367 ADSP 21368 ADSP 21369 ADSP 21371 or ADSP 21375 processor the filter coefficients and the delay line must not both be allocated in external memory otherwise the function can generate an incorrect set of results This occurs because in a dual data move instruction the hardware does not support both memory accesses allocated to external memory Therefore ensure that the filter coefficients or the delay line or optionally both are allocated in internal memory when running on one of the 213xx processors specified above Algorithm The following equation is the basis for the algorithm VisualDSP 5 0 Run Time Library Manual 2 139 for SHARC Processors DSP Run Time Library Reference k 1 JG Y xix 1 7 x h k
26. The variance functions do not return an error condition 2 266 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library Example include lt stats h gt define SIZE 256 double data SIZE double result result var data SIZE See Also mean For the ADSP 21xxx SIMD processors the varf function and var if doubles are the same size as floats uses SIMD by default Refer to Implications of Using SIMD Mode on page 2 23 for more information VisualDSP 5 0 Run Time Library Manual 2 267 for SHARC Processors DSP Run Time Library Reference vecdot Vector dot product Synopsis include lt vector h gt float vecdotf const float dm aL const float dm b int samples double vecdot const double dm aL const double dm b int samples long double vecdotd const long double dm aL const long double dm bl int samples Description The vecdot functions compute the dot product of the vectors a and bI 1 which are samples in size They return the scalar result Algorithm The following equation is the basis of the algorithm samples 1 return 3 a eb Error Conditions The vecdot functions do not return an error condition 2 268 VisualDSP 5 0 Run Time Library Manual for SHARC Processors Example include lt vector h gt itdefine N 100 double xINJ y N double answer answer vecdot x See Also cvecdot DS
27. complex_float complex_float complex_float rfft65536 rfft32768 rfft16384 xrfft8192 xrfft4096 xrfft2048 xrfft1024 prtt9l2 xrfft256 fl co fi con fl co fi co fl co fi con fl co fi co fl co oat dm input plex_float dm output oat dm input plex_float dm output oat dm input plex_float dm output oat dm input plex_float dm output oat dm input plex_float dm output oat dm input plex_float dm output oat dm input plex_float dm output oat dm input plex_float dm output oat dm input plex_float dm output VisualDSP 5 0 Run Time Library Manual for SHARC Processors 2 235 DSP Run Time Library Reference complex float rfft128 fl co complex_float rfft64 fl co complex_float rfft32 fl co complex float rfft16 fl co Description oat d plex_ oat d plex_ oat d plex_ oat d plex_ i floa i floa floa ls floa put t dm output put t dm output put t dm output put t dm output The rfftN functions are defined in the header file filter h They have been optimized to take advantage of the SIMD capabilites of the ADSP 211xx ADSP 212xx ADSP 213xx and ADSP 214xx processors They are therefore not supported by the ADSP 210xx processor family These FFT functions require complex arg
28. int cols complex double cmatsadd complex double dm output const compl ex_double dm a complex_double scalar int rows int cols complex_long_double cmatsaddd complex_long_double dm output const compl ex_long_double dm a complex_long_double scalar int rows i Description nt cols The cmatsadd functions add a complex scalar to each element of the com plex input matrix a and return the result in the matrix output The dimensions of these matrices are atrowsJCcolsJ and outputLrows cols The functions return a pointer to the output matrix Error Conditions The cmatsadd functions do not return an error condition VisualDSP 5 0 Run Time Library Manual for SHARC Processors 2 87 DSP Run Time Library Reference Example include lt cmatrix h gt define ROWS 4 define COLS 8 complex double aLROWS LCOLS a_p complex double amp a complex double cIROWSILCOLSI res_p complex_double amp c complex double z cmatsadd res p a_p z ROWS COLS See Also cmatsmlt cmatssub cmatmadd matsadd For the ADSP 21xxx SIMD processors the cmatsaddf function and cmatsadd if doubles are the same size as floats uses SIMD refer to Implications of Using SIMD Mode on page 2 23 for more information 2 88 VisualDSP 5 0 Run Time Library Manual for SHARC Processors cmatsmit DSP Run Time Library Complex matrix scalar multipl
29. loat dm real inputI loat dm imag_inputL real outputt1 f loat dm real inputI loat dm imag_inputL real outputIJ f loat dm real inputI loat dm imag_inputL real outputIJ f dm dm dm dm dm dm dm imag outputL 1 imag outputL 1 jmag_outputL imag_outputl imag_outputl imag_outputl imag_outputl Each of these cfftN functions computes the N point radix 2 Fast Fourier Transform CFFT of its floating point input where N is 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 or 65536 2 68 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library There are fourteen distinct functions in this set All perform the same function with the same type and number of arguments The only differ ence between them is the size of the arrays on which they operate Call a particular function by substituting the number of points for N as in cfft8 r_inp i_inp r_outp i_outp The input to cfftN are two floating point arrays of N points The array real_input contains the real components of the complex signal and the array imag_input contains the imaginary components If there are fewer than N actual data points you must pad the arrays with zeros to make N samples However better results occur with less zero pad ding The input data should be windowed if necessary before calling the function because no preprocessing is performed on t
30. 2 2 VisualDSP 5 0 Run Time Library Manual for SHARC Processors DSP Run Time Library Note that C namespace prefixing is not supported when calling a DSP library function All DSP library functions are in the C global namespace The function names are C function names If you call C run time library functions from an assembly language program you must use the assembly version of the function name which is the func tion name prefixed with an underscore For more information on naming conventions see Chapter 1 of the VisualDSP 5 0 Com piler Manual section C C and Assembly Interface You can use the archiver described in the VisualDSP 5 0 Linker and Utilities Manual to build library archive files of your own functions Linking DSP Library Functions When your C code calls a DSP run time library function the call creates a reference that the linker resolves when linking your program One way to direct the linker to the location of the DSP library is to use the default Linker Description File ADSP 21 lt your_target gt 1df The default Linker Description File automatically directs the linker to the appropriate library under your VisualDSP installation Table 2 1 lists the names of these libraries and where they are installed Table 2 1 DSP Run Time Library File Names Library Name Directory Processor libdsp020 dlb 21k lib ADSP 21020 processors libdsp dlb 21k lib ADSP 2106
31. 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library bsearch Perform binary search in a sorted array Synopsis include lt stdlib h gt void bsearch const void key const void base size_t nelem size_t size int compare const void const void Description The bsearch function executes a binary search operation on a pre sorted array where e key is a pointer to the element to search for e base points to the start of the array e nelem is the number of elements in the array e size is the size of each element of the array e compare points to the function used to compare two elements It takes as parameters a pointer to the key and a pointer to an array element The function should return a value less than equal to or greater than zero according to whether the first parameter is less than equal to or greater than the second The bsearch function returns a pointer to the first occurrence of key in the array Error Conditions The bsearch function returns a null pointer if the key is not found in the array VisualDSP 5 0 Run Time Library Manual 1 95 for SHARC Processors C Run Time Library Reference Example See include lt stdlib h gt char answer char base 50J 3 answer bsearch g base 50 3 Also gsort strcmp 1 96 VisualDSP 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library calloc Allocate
32. 5 0 Run Time Library Manual for SHARC Processors C C Run Time Library stcat Concatenate strings Synopsis include lt string h gt char strcat char s1 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 It returns a pointer to the new s1 string which is null t