- Page 1 and 2:
2004 Microchip Technology Inc. DS51
- Page 3 and 4:
dsPIC ®LANGUAGE TOOLS LIBRARIES 20
- Page 5 and 6:
215 4.11 variable argument lists .
- Page 7 and 8:
and macros for standard C operation
- Page 9 and 10:
This documentation is provided on t
- Page 11 and 12:
• Development Systems Information
- Page 13 and 14:
data section. The alternate startup
- Page 15 and 16:
specific libraries.) When compiling
- Page 17 and 18:
esults will occur when the function
- Page 19 and 20:
A batch file named makedsplib.batis
- Page 21 and 22:
-15 or smaller than -1.0. Analogous
- Page 23 and 24:
CORCON saved, used, restored DOand
- Page 25 and 26:
fractional* srcV ); Arguments: numE
- Page 27 and 28:
VectorCorrelateis 4 less than whate
- Page 29 and 30:
less than or equal to any previous
- Page 31 and 32:
Remarks: The negated value of 0x800
- Page 33 and 34:
Cycles (including C-function call a
- Page 35 and 36:
plus program words from VectorCopy
- Page 37 and 38:
Prototype: extern fractional* Black
- Page 39 and 40:
); Arguments: numElems number of el
- Page 41 and 42:
the base address of the matrix. Bec
- Page 43 and 44:
in default RAM memory space (X-Data
- Page 45 and 46:
0 ≤i < numRows1 0 ≤j < numCols2
- Page 47 and 48:
20 + 3(numRows*numCols) MatrixSubtr
- Page 49 and 50:
(of the same dimension) whose eleme
- Page 51 and 52:
history of the filter. After perfor
- Page 53 and 54:
Oppenheim and Ronald Schafer’s Di
- Page 55 and 56:
modulo buffer. Source samples, x[n]
- Page 57 and 58:
FIRDelayInit Description: FIRDelayI
- Page 59 and 60:
filter. Include: dsp.h Prototype: e
- Page 61 and 62:
FIRStruct* filter, fractional* refS
- Page 63 and 64:
energyEstimate estimated energy val
- Page 65 and 66:
fractional* delayBase ); Arguments:
- Page 67 and 68:
Source File: iircan.asm DSP Library
- Page 69 and 70:
srcSamps pointer to source samples
- Page 71 and 72:
} IIRTransposedStruct; extern fract
- Page 73 and 74:
no REPEATinstructions Program words
- Page 75 and 76:
Language Tools Libraries DS51456B-p
- Page 77 and 78:
for instance if: a = Op1 (b, c), wi
- Page 79 and 80:
and stores the results in the desti
- Page 81 and 82:
Description: DCTIPcomputes the Disc
- Page 83 and 84:
int log2N, fractcomplex* dstCV, fra
- Page 85 and 86:
fractcomplex* srcCV, fractcomplex*
- Page 87 and 88:
Language Tools Libraries DS51456B-p
- Page 89 and 90:
value can be calculated using the i
- Page 91 and 92:
A complex vector of size N/2 must h
- Page 93 and 94:
specific libraries. When compiling
- Page 95 and 96:
Control I/O pin definitions RW_PIN
- Page 97 and 98:
y calling the BusyXLCD()function. T
- Page 99 and 100:
COM1_COM16 COM16_COM1 Display On/Of
- Page 101 and 102:
Source File: CAN1AbortAll.c CAN2Abo
- Page 103 and 104:
char CAN2IsRXPassive(void); Argumen
- Page 105 and 106:
CAN2SendMessage Description: This f
- Page 107 and 108:
CAN2SetMask Description: This funct
- Page 109 and 110:
CAN_IDLE_CON_NO_WAITCAN On in Idle
- Page 111 and 112:
Language Tools Libraries DS51456B-p
- Page 113 and 114:
CAN_INDI_INVMESS_DIS CAN_INDI_WAK_D
- Page 115 and 116:
{ /* Length of data tobe transmitte
- Page 117 and 118:
Return Value: If the value of DONE
- Page 119 and 120:
dsPIC Peripheral Libraries 2004 Mic
- Page 121 and 122:
..... SKIP_SCAN_AN15 Return Value:
- Page 123 and 124:
DS51456B-page 100 3.5.2 Individual
- Page 125 and 126:
3.6 ADC10 FUNCTIONS This section co
- Page 127 and 128:
Module On/Off ADC_MODULE_ON ADC_MOD
- Page 129 and 130:
ADPCFG register as defined below: E
- Page 131 and 132:
ADC_CHX_NEG_SAMPLEB_AN6AN7AN8 ADC_C
- Page 133 and 134:
Scanselect = SKIP_SCAN_AN2 & SKIP_S
- Page 135 and 136:
dsPIC ® Language Tools Libraries D
- Page 137 and 138:
void OpenTimer4(unsigned int config
- Page 139 and 140:
Tx_SOURCE_EXT Tx_SOURCE_INT period
- Page 141 and 142:
3.7.2 Individual Macros WriteTimer2
- Page 143 and 144:
SetPriorityIntT4 SetPriorityIntT5 D
- Page 145 and 146:
Code Example: char reset_state; res
- Page 147 and 148:
Arguments: None Remarks: This macro
- Page 149 and 150:
stored into CNPU2 register. The upp
- Page 151 and 152:
SetPriorityInt2 SetPriorityInt3 Set
- Page 153 and 154:
IC_INT_PRIOR_3 IC_INT_PRIOR_4 IC_IN
- Page 155 and 156:
ReadCapture3 ReadCapture4 ReadCaptu
- Page 157 and 158:
dsPIC ® Language Tools Libraries D
- Page 159 and 160:
void CloseOC4(void); void CloseOC5(
- Page 161 and 162:
Include: outcompare.h Prototype: vo
- Page 163 and 164:
Include: outcompare.h Prototype: un
- Page 165 and 166:
SetDCOC3PWM SetDCOC4PWM SetDCOC5PWM
- Page 167 and 168:
Code Example: pulse_start = 0x40 ;
- Page 169 and 170:
T3CON = 0x8000; T1CON = 0X8000; /*
- Page 171 and 172:
Transmit Interrupt Priority UART_TX
- Page 173 and 174:
UART_1STOPBIT config2 This contains
- Page 175 and 176:
Source File: WriteUART1.c WriteUART
- Page 177 and 178:
Code Example: EnableIntU2TX; Disabl
- Page 179 and 180:
ConfigIntUART1(UART_RX_INT_EN & UAR
- Page 181 and 182:
DCI_INT_PRI_4 DCI_INT_PRI_5 DCI_INT
- Page 183 and 184:
DCI_FRAME_LEN_15 DCI_FRAME_LEN_14 .
- Page 185 and 186:
Prototype: unsigned int ReadDCI(uns
- Page 187 and 188:
contents are sent duringthe timeslo
- Page 189 and 190:
SPI_INT_PRI_4 SPI_INT_PRI_5 SPI_INT
- Page 191 and 192:
Prototype: void WriteSPI1(unsigned
- Page 193 and 194:
Remarks: This functions initializes
- Page 195 and 196:
2004 Microchip Technology Inc. DS51
- Page 197 and 198:
SEC_PRESCAL_7_1 & PRI_PRESCAL_64_1;
- Page 199 and 200:
enables/disables the interrupt. Sou
- Page 201 and 202:
QEI_QE_CLK_DIVIDE_1_32 QEI_QE_CLK_D
- Page 203 and 204:
} int main(void) { unsigned int max
- Page 205 and 206:
dsPIC ® Language Tools Libraries D
- Page 207 and 208:
PWM_PEN2H PWM_PDIS2H PWM_PEN1H PWM_
- Page 209 and 210:
PWM_POUT_1L Bit defines related to
- Page 211 and 212:
PWM_DTS3I_UA PWM_DTS3I_UB Dead Time
- Page 213 and 214:
PWM_OVA3H_INACTIVE PWM_OVA2H_INACTI
- Page 215 and 216:
Language Tools Libraries DS51456B-p
- Page 217 and 218:
#include #include void __attribute
- Page 219 and 220:
Prototype: void ConfigIntI2C(unsign
- Page 221 and 222:
Arguments: None Return Value None R
- Page 223 and 224:
a #definestatement in the i2c.h Sou
- Page 225 and 226:
I2C_IDLE_CON SCL Release Control bi
- Page 227 and 228:
i2c_data_wait This is the timeout c
- Page 229 and 230:
3.17.2 Individual Macros StartI2C D
- Page 231 and 232:
Arguments: None Remarks: This macro
- Page 233 and 234:
• src\libm- source code for math
- Page 235 and 236:
Remarks: The expression evaluates t
- Page 237 and 238:
if (isalpha(ch)) printf("# is alpha
- Page 239 and 240:
Remarks: A character is considered
- Page 241 and 242:
ch = '&'; if (isprint(ch)) printf("
- Page 243 and 244:
Language Tools Libraries DS51456B-p
- Page 245 and 246:
int ch; ch = 'B'; printf("B changes
- Page 247 and 248:
dsPIC ® Language Tools Libraries D
- Page 249 and 250:
DBL_MIN_10_EXP Description: Minimum
- Page 251 and 252:
Include: Value: 1 Remarks: Rounds
- Page 253 and 254:
Description: Maximum value of a lon
- Page 255 and 256:
Language Tools Libraries DS51456B-p
- Page 257 and 258:
abort - terminating See the example
- Page 259 and 260:
dsPIC ® Language Tools Libraries D
- Page 261 and 262:
} Output: Illegal instruction execu
- Page 263 and 264:
must be at least one named argument
- Page 265 and 266:
Include: Prototype: #define va_end
- Page 267 and 268:
to perform input and output operati
- Page 269 and 270:
_IOLBF Description: Indicates line
- Page 271 and 272:
Include: Prototype: void clearerr(
- Page 273 and 274:
Include: Prototype: int feof(FILE
- Page 275 and 276:
Error indicator reset Standard C Li
- Page 277 and 278:
fpos_t pos; char buf[25]; if ((myfi
- Page 279 and 280:
Description: Opens a file. Include:
- Page 281 and 282:
Explanation: afile1must exist befor
- Page 283 and 284:
Arguments: s string to be written s
- Page 285 and 286:
10.0/2 = 5.000000 10.0/3 = 3.333333
- Page 287 and 288:
Explanation: This program uses myfi
- Page 289 and 290:
SEEK_CUR- seeks from the current po
- Page 291 and 292:
*pos if successful; otherwise, fset
- Page 293 and 294:
if ((myfile = fopen("afile.out", "r
- Page 295 and 296:
10.0/2 = 5.000000 10.0/3 = 3.333333
- Page 297 and 298:
Return Value: Returns the character
- Page 299 and 300:
Standard C Libraries with Math Func
- Page 301 and 302:
e, E doublein scientific notation f
- Page 303 and 304:
putchar Description: Put a characte
- Page 305 and 306:
Output: File renamed dsPIC ® Langu
- Page 307 and 308:
® Language Tools Libraries DS51456
- Page 309 and 310:
setbuf(myfile1, NULL); printf("myfi
- Page 311 and 312:
int main(void) { char sbuf[100], s[
- Page 313 and 314:
Include: Prototype: char *tmpnam(c
- Page 315 and 316:
ungetc (Continued) Standard C Libra
- Page 317 and 318:
va_list ap; va_start(ap, fmt); prin
- Page 319 and 320:
with operands of type long. Include
- Page 321 and 322:
i = -2; printf("The absolute value
- Page 323 and 324:
Language Tools Libraries DS51456B-p
- Page 325 and 326:
(int) strtol(s,0,10)except it does
- Page 327 and 328:
eturn 0; else return 1; } Output: S
- Page 329 and 330:
printf("For div(%d, %d)\n", x, y);
- Page 331 and 332:
free Description: Frees memory. Inc
- Page 333 and 334:
printf("The absolute value of %7ld
- Page 335 and 336:
is undefined. malloc Description: A
- Page 337 and 338:
with the key Remarks: qsortoverwrit
- Page 339 and 340:
object. If reallocsucceeds in alloc
- Page 341 and 342:
optional whitespace, followed by an
- Page 343 and 344: ® Language Tools Libraries DS51456
- Page 345 and 346: Prototype: size_t wcstombs(char *s,
- Page 347 and 348: characters in s2and returns a value
- Page 349 and 350: printf("\n"); memcpy(buf1, buf3, 5)
- Page 351 and 352: printf("\n"); printf("memset(\"%s\"
- Page 353 and 354: printf("buf1 : %s\n\n", buf1); ptr
- Page 355 and 356: uf3 : Why? buf2 comes before buf1 b
- Page 357 and 358: str1, str2, res); res = strcspn(str
- Page 359 and 360: (string length = 11 characters) str
- Page 361 and 362: s2 second string n number of charac
- Page 363 and 364: printf("buf1 : %s\n", buf1); printf
- Page 365 and 366: contained in s2. Example: #include
- Page 367 and 368: else printf("%c not found\n", ch2);
- Page 369 and 370: printf("\"%s\" found at position %d
- Page 371 and 372: Output: str1 : Here, on top of the
- Page 373 and 374: MMMis month of the year ddis day of
- Page 375 and 376: Language Tools Libraries DS51456B-p
- Page 377 and 378: printf("Local time = %s\n", asctime
- Page 379 and 380: Example: #include /* for strftime,
- Page 381 and 382: (in magnitude) to be represented in
- Page 383 and 384: Argument: x value between -1 and 1
- Page 385 and 386: y = atan (x); printf("The arctangen
- Page 387 and 388: if (errno) perror("Error"); printf(
- Page 389 and 390: for (i=0; i
- Page 391 and 392: } Output: The cosine of -1.000000 i
- Page 393: Error: range error The hyperbolic c
- Page 397 and 398: y = fabs (x); printf("The absolute
- Page 399 and 400: -2.0F, -1.75F, -1.5F, -1.25F}; floa
- Page 401 and 402: x, y, z); errno = 0; x = 7.0; y = 0
- Page 403 and 404: perror("Error"); printf("For fmodf
- Page 405 and 406: Return Value: Returns the fraction,
- Page 407 and 408: printf("For a number = %fand an exp
- Page 409 and 410: ldexpf(-0.625000, 2) = -2.500000 Fo
- Page 411 and 412: x, y); errno = 0; x = 0.0; y = log1
- Page 413 and 414: NaN is returned if xis a negative n
- Page 415 and 416: Arguments: x single precision float
- Page 417 and 418: dsPIC ® Language Tools Libraries D
- Page 419 and 420: The sine of -1.000000 is -0.841471
- Page 421 and 422: The hyperbolic sine of 0.000000 is
- Page 423 and 424: Error: domain error The square root
- Page 425 and 426: Return Value: Returns the tangent o
- Page 427 and 428: x, y); } Output: The hyperbolic tan
- Page 429 and 430: the calling process's data segment.
- Page 431 and 432: eginning of the file. A return valu
- Page 433 and 434: through the simulator. The return v
- Page 435 and 436: uffer points to the storage locatio
- Page 437 and 438: div.sd __builtin_divud Description:
- Page 439 and 440: mul.uu dsPIC ® Language Tools Libr
- Page 441 and 442: Return Value: Returns the psv page
- Page 443 and 444: __builtin_mulus ...................
- Page 445 and 446:
arcsine Double Floating Point......
- Page 447 and 448:
Set Priority Macro.................
- Page 449 and 450:
isxdigit...........................
- Page 451 and 452:
String to Unsigned LongInteger ....
- Page 453 and 454:
DCT................................
- Page 455 and 456:
EnableIntlCx.......................
- Page 457 and 458:
Single Floating Point .............
- Page 459 and 460:
DBL_MAX_10_EXP ....................
- Page 461 and 462:
Single Floating Point..............
- Page 463 and 464:
tanhf .............................
- Page 465 and 466:
Set Capture Interrupt Priority ....
- Page 467 and 468:
ldiv_t ............................
- Page 469 and 470:
long long unsigned int Maximum Valu
- Page 471 and 472:
MatrixInvert ......................
- Page 473 and 474:
Single Floating Point..............
- Page 475 and 476:
system.............................
- Page 477 and 478:
Quick Sort ........................
- Page 479 and 480:
SEEK_SET...........................
- Page 481 and 482:
Minimum Value .....................
- Page 483 and 484:
va_arg ............................
- Page 485 and 486:
atoi ..............................
- Page 487 and 488:
strncpy ...........................
- Page 489 and 490:
Write..............................
- Page 491 and 492:
unsigned short int Maximum Value ..
- Page 493 and 494:
Zero, divide by....................
- Page 495 and 496:
Tel: 86-532-502-7355 Fax: 86-532-50