™
mikroC PRO for dsPIC
mikroC PRO for dsPIC30/33 and PIC24 is a full-featured C compiler
for dsPIC30, dsPIC33 and PIC24 MCUs from Microchip. It is designed
for developing, building and debugging dsPIC30/33 and PIC24based embedded applications. This development environment has a
wide range of features such as: easy-to-use IDE, very compact and
efcient code, many hardware and software libraries, comprehensive
documentation, software simulator, COFF le generation, SSA
optimization (up to 30% code reduction) and many more. Numerous
ready-to-use and well-explained examples will give a good start for
your embedded project.
Manual
Compiler
MikroElektronika
mikoC PRO for dsPIC
Table of Contents
CHAPTER 1 32
INTRODUCTION 32
Introduction to mikroC PRO for dsPIC30/33 and PIC24 33
Features 33
Where to Start 33
What’s new in mikroC PRO for dsPIC30/33 and PIC24 34
Compiler Changes 34
IDE Changes 34
Software License Agreement 35
mikroElektronika Associates License Statement and Limited Warranty 35
IMPORTANT - READ CAREFULLY 35
LIMITED WARRANTY 35
HIGH RISK ACTIVITIES 36
GENERAL PROVISIONS 36
Technical Support 37
How to Register 37
Who Gets the License Key 37
How to Get License Key 37
After Receving the License Key 39
CHAPTER 2 41
mikroC PRO for dsPIC30/33 and PIC24 Environment 41
Main Menu Options 42
File 43
File Menu Options 43
Edit 44
Edit Menu Options 44
Find Text 45
Replace Text 45
Find In Files 46
Go To Line 46
Regular expressions option 46
View 47
View Menu Options 47
Project 49
Project Menu Options 49
Build 50
Build Menu Options 50
Run 51
Run Menu Options 51
Tools 52
Tools Menu Options 52
MikroElektronika
2
mikroC PRO for dsPIC
Help 53
Help Menu Options 53
mikroC PRO for dsPIC30/33 and PIC24 IDE 54
IDE Overview 54
Code Editor 55
Editor Settings 55
Auto Save 56
Highlighter 56
Spelling 56
Comment Style 56
Code Folding 56
Code Assistant 57
Parameter Assistant 57
Bookmarks 57
Go to Line 57
Column Select Mode 58
Editor Colors 58
Auto Correct 59
Auto Complete (Code Templates) 60
Code Explorer 62
Routine List 63
Project Manager 63
Project Settings 65
Library Manager 66
Managing libraries using Package Manager 67
Statistics 68
Memory Usage Windows 68
RAM Memory Usage 69
Used RAM Locations 69
SFR Locations 70
ROM Memory Usage 70
ROM Memory Constants 71
Functions 71
Functions Sorted By Name Chart 72
Functions Sorted By Size Chart 72
Functions Sorted By Addresses 73
Function Tree 73
Memory Summary 74
Messages Window 75
Quick Converter 76
Macro Editor 76
Image Preview 77
Toolbars 79
File Toolbar 80
Edit Toolbar 80
3
MikroElektronika
mikoC PRO for dsPIC
Advanced Edit Toolbar 81
Find/Replace Toolbar 81
Project Toolbar 82
Build Toolbar 82
Debug Toolbar 83
Styles Toolbar 83
Tools Toolbar 84
View Toolbar 84
Layout Toolbar 85
Help Toolbar 85
Customizing IDE Layout 86
Docking Windows 86
Saving Layout 87
Auto Hide 87
Options 88
Code editor 88
Tools 88
Output settings 89
Integrated Tools 91
Active Comments Editor 91
ASCII Chart 92
EEPROM Editor 93
Filter Designer 93
Graphic Lcd Bitmap Editor 94
HID Terminal 95
Lcd Custom Character 96
Seven Segment Editor 97
UDP Terminal 97
USART Terminal 98
Active Comments 99
New Active Comment 99
Renaming Active Comment 106
Deleting Active Comment 107
Export Project 108
Jump To Interrupt 109
Regular Expressions 110
Introduction 110
Simple matches 110
Escape sequences 110
Character classes 110
Metacharacters 111
Metacharacters - Line separators 111
Metacharacters - Predened classes 11 2
Metacharacters - Word boundaries 112
Metacharacters - Iterators 112
Metacharacters - Alternatives 113
MikroElektronika
4
mikroC PRO for dsPIC
Metacharacters - Subexpressions 113
Metacharacters - Backreferences 113
Keyboard Shortcuts 114
CHAPTER 3 116
mikroC PRO for dsPIC30/33 and PIC24 Command Line Options 116
CHAPTER 4 118
mikroICD (In-Circuit Debugger) 118
Introduction 118
mikroICD Debugger Options 120
Debugger Options 120
mikroICD Debugger Example 121
mikroICD Debugger Windows 125
Debug Windows 125
Breakpoints Window 125
Watch Values Window 125
RAM Window 127
Stopwatch Window 127
EEPROM Watch Window 128
Code Watch Window 129
CHAPTER 5 130
Software Simulator Overview 130
Software Simulator 131
Software Simulator Debug Windows 132
Debug Windows 132
Breakpoints Window 132
Watch Values Window 132
RAM Window 134
Stopwatch Window 134
EEPROM Watch Window 135
Code Watch Window 136
Software Simulator Debugger Options 137
Debugger Options 137
CHAPTER 6 138
mikroC PRO for dsPIC30/33 and PIC24 Specics 13 8
GOTO Table 139
ANSI Standard Issues 140
Divergence from the ANSI C Standard 140
C Language Extensions 140
Implementation-dened Behavior 140
Predened Globals and Constants 141
Predened project level denes 141
Accessing Individual Bits 142
sbit type 143
5
MikroElektronika
mikoC PRO for dsPIC
at keyword 144
bit type 144
Interrupts 145
Function Calls from Interrupt 145
Disable Context Saving 145
Interrupt Handling 145
Interrupt Example 146
Linker Directives 147
Directive absolute 147
Directive orgall 147
Directive funcorg 148
Indirect Function Calls 148
Built-in Routines 149
Lo 150
Hi 150
Higher 151
Highest 151
LoWord 152
HiWord 152
Delay_us 153
Delay_ms 153
Vdelay_ms 153
VDelay_Advanced_ms 154
Delay_Cyc 154
Delay_Cyc_Long 154
Clock_kHz 155
Clock_Mhz 155
Get_Fosc_kHz 155
Get_Fosc_Per_Cyc 156
Code Optimization 157
Constant folding 157
Constant propagation 157
Copy propagation 157
Value numbering 157
"Dead code" ellimination 157
Stack allocation 157
Local vars optimization 157
Better code generation and local optimization 157
Single Static Assignment Optimization 158
Introduction 158
Proper Coding Recommendations 159
Asm code and SSA optimization 160
Debugging Notes 160
Warning Messages Enhancement 160
Common Object File Format (COFF) 161
COFF File Format 161
MikroElektronika
6
mikroC PRO for dsPIC
COFF File Generation 161
CHAPTER 7 163
dsPIC30/33 and PIC24 Specics 16 3
Types Efciency 16 4
Nested Calls Limitations 164
Limits of Indirect Approach Through PSV 164
Limits of Pointer to Function 164
Variable, constant and routine alignment 164
dsPIC Memory Organization 165
Program Memory (ROM) 165
Data Memory (RAM) 166
SFR Memory Space 166
X and Y Data RAM 166
DMA RAM 167
Unimplemented Memory Space 167
Memory Type Speciers 16 8
code 168
data 168
rx 168
sfr 168
xdata 169
ydata 169
dma 169
Memory Type Qualiers 170
Near Memory Qualier 170
Far Memory Qualier 170
Read Modify Write Problem 171
CHAPTER 8 175
mikroC PRO for dsPIC30/33 and PIC24 Language Reference 175
Lexical Elements Overview 178
Whitespace 179
Whitespace in Strings 179
Line Splicing with Backslash (\) 179
Comments 180
C comments 180
C++ comments 180
Nested comments 180
Tokens 181
Token Extraction Example 181
Constants 182
Integer Constants 182
Long and Unsigned Sufxes 18 2
Decimal 182
Hexadecimal 183
7
MikroElektronika
mikoC PRO for dsPIC
Binary 183
Octal 183
Floating Point Constants 184
Character Constants 184
Escape Sequences 184
Disambiguation 185
String Constants 186
Line Continuation with Backslash 186
Enumeration Constants 187
Pointer Constants 187
Constant Expressions 188
Keywords 189
Identiers 19 0
Case Sensitivity 190
Uniqueness and Scope 191
Identier Examples 19 1
Punctuators 191
Brackets 191
Parentheses 192
Braces 192
Comma 192
Semicolon 193
Colon 193
Asterisk (Pointer Declaration) 193
Equal Sign 194
Pound Sign (Preprocessor Directive) 194
Concepts 195
Objects 195
Objects and Declarations 195
Lvalues 196
Rvalues 196
Scope and Visibility 196
Scope 196
Visibility 196
Name Spaces 197
Duration 198
Static Duration 198
Local Duration 198
Types 199
Type Categories 199
Fundamental Types 200
Arithmetic Types 200
Integral Types 200
Floating-point Types 201
MikroElektronika
8
mikroC PRO for dsPIC
Enumerations 201
Enumeration Declaration 201
Anonymous Enum Type 202
Enumeration Scope 202
Void Type 203
Void Functions 203
Generic Pointers 203
Derived Types 203
Arrays 204
Array Declaration 204
Array Initialization 204
Arrays in Expressions 205
Multi-dimensional Arrays 205
Pointers 206
Pointer Declarations 206
Null Pointers 207
Assign an address to a Function Pointer 207
Function Pointers 209
Assign an address to a Function Pointer 209
Pointer Arithmetic 210
Arrays and Pointers 210
Assignment and Comparison 211
Pointer Addition 212
Pointer Subtraction 213
Structures 213
Structure Declaration and Initialization 213
Incomplete Declarations 214
Untagged Structures and Typedefs 215
Anonymous Structures 215
Working with Structures 216
Assignment 216
Size of Structure 216
Structures and Functions 216
Structure Member Access 217
Accessing Nested Structures 218
Structure Uniqueness 218
Unions 219
Union Declaration 219
Size of Union 219
Union Member Access 219
Anonymous Unions 220
Anonymous Union Member Access 220
Bit Fields 221
Bit Fields Declaration 221
Bit Fields Access 222
9
MikroElektronika
mikoC PRO for dsPIC
Types Conversions 222
Standard Conversions 223
Arithmetic Conversions 223
Pointer Conversions 224
Explicit Types Conversions (Typecasting) 224
Declarations 225
Declarations and Denitions 22 5
Declarations and Declarators 226
Linkage 226
Linkage Rules 227
Internal Linkage Rules 227
Storage Classes 227
Auto 228
Register 228
Static 228
Extern 228
Type Qualiers 229
Qualier const 229
Qualier volatile 229
Typedef Specier 229
asm Declaration 230
Accessing variables 230
Asm code and SSA optimization 231
Initialization 232
Automatic Initialization 232
Functions 233
Function Declaration 233
Function Prototypes 234
Function Denition 23 4
Functions reentrancy 235
Function Calls and Argument Conversions 235
Function Calls 235
Argument Conversions 236
Ellipsis (‘...’) Operator 237
Operators 238
Operators Precedence and Associativity 239
Binary Arithmetic Operators 240
Unary Arithmetic Operators 240
Relational Operators 241
Relational Operators Overview 241
Relational Operators in Expressions 241
Bitwise Operators 242
Bitwise Operators Overview 242
Logical Operations on Bit Level 242
MikroElektronika
10
mikroC PRO for dsPIC
Bitwise Shift Operators 243
Bitwise vs. Logical 243
Logical Operators 244
Logical Operators Overview 244
Logical Operations 244
Logical Expressions and Side Effects 244
Logical vs. Bitwise 245
Conditional Operator ? : 245
Conditional Operator Rules 245
Assignment Operators 246
Simple Assignment Operator 246
Compound Assignment Operators 246
Assignment Rules 246
Unary Operators 247
Unary Arithmetic Operators 247
Unary Logical Operator 248
Unary Bitwise Operator 248
Address and Indirection Operator 248
Sizeof Operator 249
Sizeof Applied to Expression 249
Sizeof Applied to Type 249
Expressions 250
Comma Expressions 250
Statements 251
Labeled Statements 251
Expression Statements 252
Selection Statements 252
If Statement 252
Nested If statements 252
Switch Statement 253
Nested switch 254
Iteration Statements (Loops) 254
While Statement 254
Do Statement 254
For Statement 255
Jump Statements 256
Break and Continue Statements 256
Break Statement 256
Continue Statement 256
Goto Statement 257
Return Statement 257
Compound Statements (Blocks) 258
Preprocessor 258
11
MikroElektronika
mikoC PRO for dsPIC
Preprocessor Directives 258
Line Continuation with Backslash (\) 259
Macros 259
Dening Macros and Macro Expansions 25 9
Macros with Parameters 260
Undening Macros 26 1
File Inclusion 261
Explicit Path 262
Preprocessor Operators 263
Operator # 263
Operator ## 263
Conditional Compilation 264
Directives #if, #elif, #else, and #endif 264
Directives #ifdef and #ifndef 265
CHAPTER 9 266
mikroC PRO for dsPIC30/33 and PIC24 Libraries 266
Hardware Libraries 267
Digital Signal Processing Libraries 267
Standard ANSI C Libraries 268
Miscellaneous Libraries 268
Hardware Libraries 269
ADC Library 269
Library Routines 270
ADCx_Init 270
ADCx_Init_Advanced 271
ADCx_Get_Sample 272
ADCx_Read 272
ADC_Set_Active 273
Library Example 273
CAN Library 275
Library Routines 275
CANxSetOperationMode 276
CANxGetOperationMode 276
CANxInitialize 277
CANxSetBaudRate 278
CANxSetMask 279
CANxSetFilter 280
CANxRead 281
CANxWrite 282
CAN Constants 283
CAN_OP_MODE Constants 283
CAN_CONFIG_FLAGS Constants 283
CAN_TX_MSG_FLAGS Constants 284
CAN_RX_MSG_FLAGS Constants 285
MikroElektronika
12
mikroC PRO for dsPIC
CAN_MASK Constants 285
CAN_FILTER Constants 286
Library Example 286
HW Connection 289
CANSPI Library 290
Library Dependency Tree 290
External dependencies of CANSPI Library 290
Library Routines 291
CANSPISetOperationMode 291
CANSPIGetOperationMode 292
CANSPIInitialize 292
CANSPISetBaudRate 294
CANSPISetMask 295
CANSPISetFilter 296
CANSPIRead 297
CANSPIWrite 298
CANSPI Constants 298
CANSPI_OP_MODE Constants 298
CANSPI_TX_MSG_FLAGS Constants 300
CANSPI_RX_MSG_FLAGS Constants 300
CANSPI_MASK Constants 301
CANSPI_FILTER Constants 301
Library Example 302
HW Connection 305
Compact Flash Library 306
Library Dependency Tree 306
External dependencies of Compact Flash Library 307
Library Routines 308
Cf_Init 309
Cf_Detect 310
Cf_Enable 310
Cf_Disable 310
Cf_Read_Init 311
Cf_Read_Byte 311
Cf_Write_Init 311
Cf_Write_Byte 312
Cf_Read_Sector 312
Cf_Write_Sector 312
Cf_Fat_Init 313
Cf_Fat_QuickFormat 313
Cf_Fat_Assign 314
Cf_Fat_Reset 315
Cf_Fat_Read 315
Cf_Fat_Rewrite 316
Cf_Fat_Append 316
Cf_Fat_Delete 316
Cf_Fat_Write 317
13
MikroElektronika
mikoC PRO for dsPIC
Cf_Fat_Set_File_Date 317
Cf_Fat_Get_File_Date 318
Cf_Fat_Get_File_Date_Modied 31 8
Cf_Fat_Get_File_Size 319
Cf_Fat_Get_Swap_File 319
Library Example 321
HW Connection 323
ECAN Library 324
Library Routines 324
ECANxDmaChannelInit 325
ECANxSetOperationMode 325
ECANxGetOperationMode 326
ECANxInitialize 327
ECANxSelectTxBuffers 328
ECANxFilterDisable 328
ECANxFilterEnable 329
ECANxSetBufferSize 329
ECANxSetBaudRate 330
ECANxSetMask 331
ECANxSetFilter 332
ECANxRead 333
ECANxWrite 334
ECAN Constants 335
ECAN_OP_MODE Constants 335
ECAN_CONFIG_FLAGS Constants 335
ECAN_TX_MSG_FLAGS Constants 336
ECAN_RX_MSG_FLAGS Constants 336
ECAN_MASK Constants 337
ECAN_FILTER Constants 337
ECAN_RX_BUFFER Constants 338
Library Example 339
HW Connection 343
EEPROM Library 343
Library Routines 343
EEPROM_Erase 344
EEPROM_Erase_Block 344
EEPROM_Read 344
EEPROM_Write 345
EEPROM_Write_Block 345
Library Example 345
Epson S1D13700 Graphic Lcd Library 347
External dependencies of the Epson S1D13700 Graphic Lcd Library 347
Library Routines 348
S1D13700_Init 349
S1D13700_Write_Command 350
S1D13700_Write_Parameter 351
S1D13700_Read_Parameter 351
MikroElektronika
14
mikroC PRO for dsPIC
S1D13700_Fill 351
S1D13700_GrFill 352
S1D13700_TxtFill 352
S1D13700_Display_GrLayer 352
S1D13700_Display_TxtLayer 353
S1D13700_Set_Cursor 353
S1D13700_Display_Cursor 354
S1D13700_Write_Char 354
S1D13700_Write_Text 355
S1D13700_Dot 355
S1D13700_Line 356
S1D13700_H_Line 356
S1D13700_V_Line 357
S1D13700_Rectangle 357
S1D13700_Box 358
S1D13700_Rectangle_Round_Edges 358
S1D13700_Rectangle_Round_Edges_Fill 359
S1D13700_Circle 359
S1D13700_Circle_Fill 360
S1D13700_Image 360
S1D13700_PartialImage 361
Flash Memory Library 362
dsPIC30: 362
PIC24 and dsPIC33: 362
24F04KA201 and 24F16KA102 Family Specics : 36 3
Library Routines 363
dsPIC30 Functions 363
PIC24 and dsPIC33 Functions 363
dsPIC30 Functions 363
FLASH_Erase32 364
FLASH_Write_Block 364
FLASH_Write_Compact 365
FLASH_Write_Init 365
FLASH_Write_Loadlatch4 366
FLASH_Write_Loadlatch4_Compact 367
FLASH_Write_DoWrite 368
FLASH_Read4 368
FLASH_Read4_Compact 369
PIC24 and dsPIC33 Functions 369
FLASH_Erase 369
FLASH_Write 370
FLASH_Write_Compact 370
FLASH_Read 371
FLASH_Read_Compact 371
Library Example 372
Graphic Lcd Library 373
Library Dependency Tree 373
15
MikroElektronika
mikoC PRO for dsPIC
External dependencies of Graphic Lcd Library 374
Glcd_Init 375
Glcd_Set_Side 377
Glcd_Set_X 377
Glcd_Set_Page 377
Glcd_Read_Data 378
Glcd_Write_Data 378
Glcd_Fill 379
Glcd_Dot 379
Glcd_Line 379
Glcd_V_Line 380
Glcd_H_Line 380
Glcd_Rectangle 381
Glcd_Rectangle_Round_Edges 381
Glcd_Rectangle_Round_Edges_Fill 382
Glcd_Box 382
Glcd_Circle 383
Glcd_Circle_Fill 383
Glcd_Set_Font 384
Glcd_Write_Char 385
Glcd_Write_Text 385
Glcd_Image 386
Glcd_PartialImage 386
Library Example 387
HW Connection 389
I²C Library 390
Library Routines 390
I2Cx_Init 390
I2Cx_Start 391
I2Cx_Restart 391
I2Cx_Is_Idle 392
I2Cx_Read 392
I2Cx_Write 393
I2Cx_Stop 393
Library Example 394
HW Connection 394
Keypad Library 395
External dependencies of Keypad Library 395
Library Routines 395
Keypad_Init 395
Keypad_Key_Press 396
Keypad_Key_Click 396
Library Example 397
HW Connection 398
Lcd Library 399
Library Dependency Tree 399
Keypad_Key_Click 399
MikroElektronika
16
mikroC PRO for dsPIC
Library Routines 399
Lcd_Init 400
Lcd_Out 401
Lcd_Out_Cp 401
Lcd_Chr 401
Lcd_Chr_Cp 402
Lcd_Cmd 402
Available Lcd Commands 402
Library Example 403
Manchester Code Library 405
Keypad_Key_Click 405
Library Routines 406
Man_Receive_Init 406
Man_Receive 407
Man_Send_Init 407
Man_Send 408
Man_Synchro 408
Man_Break 409
Library Example 410
Connection Example 412
Multi Media Card Library 413
Secure Digital Card 413
Secure Digital High Capacity Card 413
Library Dependency Tree 414
External dependencies of MMC Library 414
Library Routines 414
Mmc_Init 415
Mmc_Read_Sector 416
Mmc_Write_Sector 416
Mmc_Read_Cid 417
Mmc_Read_Csd 417
Mmc_Fat_Init 418
Mmc_Fat_QuickFormat 419
Mmc_Fat_Assign 420
Mmc_Fat_Reset 421
Mmc_Fat_Read 421
Mmc_Fat_Rewrite 422
Mmc_Fat_Append 422
Mmc_Fat_Delete 422
Mmc_Fat_Write 423
Mmc_Fat_Set_File_Date 423
Mmc_Fat_Get_File_Date 424
Mmc_Fat_Get_File_Date_Modied 42 5
Mmc_Fat_Get_File_Size 425
Mmc_Fat_Get_Swap_File 426
Library Example 427
HW Connection 431
17
MikroElektronika
mikoC PRO for dsPIC
OneWire Library 432
Library Routines 432
Ow_Reset 432
Ow_Read 433
Ow_Write 433
Library Example 434
HW Connection 436
Peripheral Pin Select Library 437
Library Routines 437
Unlock_IOLOCK 437
Lock_IOLOCK 437
PPS_Mapping 438
Direction Parameters 438
Input Functions 438
Output Functions 439
Port Expander Library 441
Library Dependency Tree 441
External dependencies of Port Expander Library 441
Library Routines 441
Expander_Init 442
Expander_Init_Advanced 443
Expander_Read_Byte 444
Expander_Write_Byte 444
Expander_Read_PortA 444
Expander_Read_PortB 445
Expander_Read_PortAB 445
Expander_Write_PortA 446
Expander_Write_PortB 446
Expander_Write_PortAB 447
Expander_Set_DirectionPortA 447
Expander_Set_DirectionPortB 448
Expander_Set_DirectionPortAB 448
Expander_Set_PullUpsPortA 448
Expander_Set_PullUpsPortB 449
Expander_Set_PullUpsPortAB 449
HW Connection 451
PS/2 Library 452
External dependencies of PS/2 Library 452
Library Routines 452
Ps2_Cong 45 3
Ps2_Key_Read 453
Special Function Keys 454
Library Example 455
HW Connection 456
PWM Library 456
Library Routines 456
MikroElektronika
18
mikroC PRO for dsPIC
PWM_Init 457
PWM_Set_Duty 457
PWM_Start 458
PWM_Stop 458
Library Example 458
HW Connection 460
PWM Motor Control Library 460
Library Routines 460
PWMx_Mc_Init 461
PWMx_Mc_Set_Duty 462
PWMx_Mc_Start 462
PWMx_Mc_Stop 463
HW Connection 464
RS-485 Library 464
Library Dependency Tree 465
External dependencies of RS-485 Library 465
Library Routines 465
RS485Master_Init 465
RS485Master_Receive 466
RS485Master_Send 466
RS485Slave_Init 467
RS485Slave_Receive 468
RS485Slave_Send 468
Library Example 469
HW Connection 472
Message format and CRC calculations 473
Software I²C Library 474
External dependencies of Software I²C Library 474
Library Routines 474
Soft_I2C_Init 475
Soft_I2C_Start 475
Soft_I2C_Read 476
Soft_I2C_Write 476
Soft_I2C_Stop 477
Soft_I2C_Break 478
Library Example 479
Software SPI Library 481
External dependencies of Software SPI Library 481
Library Routines 481
Soft_SPI_Init 482
Soft_SPI_Read 483
Soft_SPI_Write 483
Library Example 483
Software UART Library 485
Library Routines 485
Soft_UART_Init 485
19
MikroElektronika
mikoC PRO for dsPIC
Soft_UART_Read 486
Soft_UART_Write 486
Soft_UART_Break 487
Library Example 488
Sound Library 489
Library Routines 489
Sound_Init 489
Sound_Play 489
HW Connection 491
SPI Library 492
Library Routines 492
SPIx_Init 493
SPIx_Init_Advanced 494
SPIx_Read 496
SPIx_Write 496
SPI_Set_Active 497
Library Example 497
HW Connection 498
SPI Ethernet Library 499
Library Dependency Tree 499
External dependencies of SPI Ethernet Library 500
Library Routines 501
SPIx_Write 501
SPIx_Write 502
SPI_Ethernet_Enable 503
SPI_Ethernet_Disable 504
SPI_Ethernet_doPacket 505
SPI_Ethernet_putByte 505
SPI_Ethernet_putBytes 506
SPI_Ethernet_putConstBytes 506
SPI_Ethernet_putString 506
SPI_Ethernet_putConstString 507
SPI_Ethernet_getByte 507
SPI_Ethernet_getBytes 507
SPI_Ethernet_UserTCP 508
SPI_Ethernet_UserUDP 509
SPI_Ethernet_getIpAddress 510
SPI_Ethernet_getDnsIpAddress 510
SPI_Ethernet_getIpMask 510
SPI_Ethernet_confNetwork 511
SPI_Ethernet_arpResolve 511
SPI_Ethernet_sendUDP 512
SPI_Ethernet_dnsResolve 512
SPI_Ethernet_initDHCP 513
SPI_Ethernet_doDHCPLeaseTime 514
SPI_Ethernet_renewDHCP 514
Library Example 515
MikroElektronika
20
mikroC PRO for dsPIC
HW Connection 522
SPI Ethernet ENC24J600 Library 523
Library Dependency Tree 523
External dependencies of SPI Ethernet ENC24J600 Library 524
Library Routines 525
SPI_Ethernet_24j600_Init 526
SPI_Ethernet_24j600_Enable 528
SPI_Ethernet_24j600_Disable 529
SPI_Ethernet_24j600_doPacket 530
SPI_Ethernet_24j600_putByte 530
SPI_Ethernet_24j600_putBytes 531
SPI_Ethernet_24j600_putConstBytes 531
SPI_Ethernet_24j600_putString 532
SPI_Ethernet_24j600_putConstString 532
SPI_Ethernet_24j600_getByte 532
SPI_Ethernet_24j600_getBytes 533
SPI_Ethernet_24j600_UserTCP 533
SPI_Ethernet_24j600_UserUDP 534
SPI_Ethernet_24j600_getIpAddress 534
SPI_Ethernet_24j600_getGwIpAddress 535
SPI_Ethernet_24j600_getDnsIpAddress 535
SPI_Ethernet_24j600_getIpMask 536
SPI_Ethernet_24j600_confNetwork 536
SPI_Ethernet_24j600_arpResolve 537
SPI_Ethernet_24j600_sendUDP 537
SPI_Ethernet_24j600_dnsResolve 538
SPI_Ethernet_24j600_initDHCP 539
SPI_Ethernet_24j600_doDHCPLeaseTime 540
SPI_Ethernet_24j600_renewDHCP 540
Library Example 540
SPI Graphic Lcd Library 541
Library Dependency Tree 541
External dependencies of SPI Lcd Library 541
Library Routines 541
SPI_Glcd_Init 542
SPI_Glcd_Set_Side 543
SPI_Glcd_Set_Page 543
SPI_Glcd_Set_X 543
SPI_Glcd_Read_Data 544
SPI_Glcd_Write_Data 544
SPI_Glcd_Fill 545
SPI_Glcd_Dot 545
SPI_Glcd_Line 546
SPI_Glcd_V_Line 546
SPI_Glcd_H_Line 547
SPI_Glcd_Rectangle 547
SPI_Glcd_Rectangle_Round_Edges 548
21
MikroElektronika
mikoC PRO for dsPIC
SPI_Glcd_Rectangle_Round_Edges_Fill 548
SPI_Glcd_Box 549
SPI_Glcd_Circle 549
SPI_Glcd_Circle_FIll 550
SPI_Glcd_Set_Font 551
SPI_Glcd_Write_Char 552
SPI_Glcd_Write_Text 552
SPI_Glcd_Image 553
SPI_Glcd_PartialImage 553
Library Example 554
HW Connection 556
SPI Lcd Library 557
Library Dependency Tree 557
External dependencies of SPI Lcd Library 557
Library Routines 557
SPI_Lcd_Cong 55 8
SPI_Lcd_Out 558
SPI_Lcd_Out_Cp 559
SPI_Lcd_Chr 559
SPI_Lcd_Chr_Cp 559
SPI_Lcd_Cmd 560
SPI_Lcd_Cmd 560
Library Example 561
Default Pin Conguration 56 1
SPI Lcd8 (8-bit interface) Library 563
Library Dependency Tree 563
External dependencies of SPI Lcd Library 563
Library Routines 563
SPI_Lcd8_Cong 56 4
SPI_Lcd8_Out 565
SPI_Lcd8_Out_Cp 565
SPI_Lcd8_Chr 565
SPI_Lcd8_Chr_Cp 566
SPI_Lcd8_Cmd 566
Available SPI Lcd8 Commands 567
Library Example 567
SPI T6963C Graphic Lcd Library 570
Library Dependency Tree 570
External dependencies of SPI T6963C Graphic Lcd Library 570
Library Routines 571
SPI_Lcd8_Cmd 572
SPI_T6963C_writeData 573
SPI_T6963C_writeCommand 573
SPI_T6963C_setPtr 574
SPI_T6963C_waitReady 574
SPI_T6963C_ll 57 4
SPI_T6963C_dot 575
MikroElektronika
22
mikroC PRO for dsPIC
SPI_T6963C_write_char 575
SPI_T6963C_write_text 576
SPI_T6963C_line 577
SPI_T6963C_rectangle 577
SPI_T6963C_rectangle_round_edges 578
SPI_T6963C_rectangle_round_edges_ll 57 8
SPI_T6963C_box 579
SPI_T6963C_circle 579
SPI_T6963C_circle_ll 57 9
SPI_T6963C_image 580
SPI_T6963C_PartialImage 580
SPI_T6963C_sprite 581
SPI_T6963C_set_cursor 581
SPI_T6963C_clearBit 581
SPI_T6963C_setBit 582
SPI_T6963C_negBit 582
SPI_T6963C_displayGrPanel 582
SPI_T6963C_displayTxtPanel 583
SPI_T6963C_setGrPanel 583
SPI_T6963C_setTxtPanel 583
SPI_T6963C_panelFill 584
SPI_T6963C_grFill 584
SPI_T6963C_txtFill 584
SPI_T6963C_cursor_height 585
SPI_T6963C_graphics 585
SPI_T6963C_text 585
SPI_T6963C_cursor 586
SPI_T6963C_cursor_blink 586
Library Example 586
HW Connection 591
T6963C Graphic Lcd Library 592
Library Dependency Tree 592
Library Dependency Tree 593
Library Routines 594
SPI_T6963C_cursor 595
T6963C_writeData 596
T6963C_writeCommand 597
T6963C_setPtr 597
T6963C_waitReady 597
T6963C_ll 59 8
T6963C_dot 598
T6963C_write_char 599
T6963C_write_text 600
T6963C_line 600
T6963C_rectangle 601
T6963C_rectangle_round_edges 601
T6963C_rectangle_round_edges_ll 60 2
23
MikroElektronika
mikoC PRO for dsPIC
T6963C_box 602
T6963C_circle 602
T6963C_circle_ll 60 3
T6963C_image 603
T6963C_PartialImage 604
T6963C_sprite 604
T6963C_set_cursor 605
T6963C_clearBit 605
T6963C_setBit 605
T6963C_negBit 606
T6963C_displayGrPanel 606
T6963C_displayTxtPanel 606
T6963C_setGrPanel 607
T6963C_setTxtPanel 607
T6963C_panelFill 607
T6963C_grFill 608
T6963C_txtFill 608
T6963C_cursor_height 608
T6963C_graphics 609
T6963C_text 609
T6963C_cursor 609
T6963C_cursor_blink 610
Library Example 610
HW Connection 614
TFT Library 615
External dependencies of TFT Library 615
Library Routines 616
TFT_Init 617
TFT_Set_Index 618
TFT_Write_Command 618
TFT_Write_Data 618
TFT_Set_Active 619
TFT_Set_Font 620
TFT_Write_Char 621
TFT_Write_Text 621
TFT_Fill_Screen 622
TFT_Dot 623
TFT_Set_Pen 624
TFT_Set_Brush 625
TFT_Line 627
TFT_H_Line 628
TFT_V_Line 628
TFT_Rectangle_Round_Edges 629
TFT_Circle 629
TFT_Image 629
TFT_Partial_Image 630
TFT_Image_Jpeg 630
MikroElektronika
24
mikroC PRO for dsPIC
TFT_RGBToColor16bit 631
TFT_Color16bitToRGB 631
HW Connection 632
Touch Panel Library 633
Library Dependency Tree 633
External dependencies of Touch Panel Library 633
Library Routines 633
TP_Init 634
TP_Set_ADC_Threshold 634
TP_Press_Detect 635
TP_Get_Coordinates 636
TP_Calibrate_Bottom_Left 636
TP_Calibrate_Upper_Right 637
TP_Get_Calibration_Consts 637
TP_Set_Calibration_Consts 638
Library Example 638
Touch Panel TFT Library 643
Library Dependency Tree 643
External dependencies of Touch Panel TFT Library 643
Library Routines 643
TP_TFT_Init 644
TP_TFT_Set_ADC_Threshold 644
TP_TFT_Press_Detect 645
TP_TFT_Get_Coordinates 646
TP_TFT_Calibrate_Min 646
TP_TFT_Calibrate_Max 647
TP_TFT_Get_Calibration_Consts 647
TP_TFT_Set_Calibration_Consts 648
HW Connection 648
UART Library 649
Library Routines 649
UARTx_Init 650
UARTx_Init_Advanced 651
UARTx_Data_Ready 653
UARTx_Tx_Idle 654
UARTx_Read 655
UARTx_Read_Text 656
UARTx_Write 657
UARTx_Write_Text 658
UART_Set_Active 659
Library Example 660
HW Connection 661
USB Library 662
USB HID Class 662
Library Routines 662
HID_Enable 663
25
MikroElektronika
mikoC PRO for dsPIC
HID_Read 663
HID_Write 664
HID_Disable 664
USB_Interrupt_Proc 665
USB_Polling_Proc 665
Gen_Enable 666
Gen_Read 666
Gen_Write 667
Library Example 668
HW Connection 668
DSP Libraries 669
Digital Signal Processing Libraries 669
FIR Filter Library 670
Library Routines 670
FIR_Radix 670
IIR Filter Library 671
Library Routines 671
IIR_Radix 671
FFT Library 672
Library Dependency Tree 672
FFT 672
Twiddle Factors: 673
TwiddleCoeff_64 673
TwiddleCoeff_128 673
TwiddleCoeff_256 674
TwiddleCoeff_512 674
Bit Reverse Complex Library 676
Library Routines 676
BitReverseComplex 676
Vectors Library 677
Library Routines 677
Vector_Set 677
Vector_Power 678
Vector_Subtract 678
Vector_Scale 679
Vector_Negate 679
Vector_Multiply 680
Vector_Min 680
Vector_Max 681
Vector_Dot 681
Vector_Correlate 682
Vector_Convolve 683
Vector_Add 684
Matrices Library 685
Library Routines 685
Matrix_Transpose 685
MikroElektronika
26
mikroC PRO for dsPIC
Matrix_Subtract 686
Matrix_Scale 686
Matrix_Multiply 687
Matrix_Add 688
Standard ANSI C Libraries 689
ANSI C Ctype Library 689
Library Functions 689
isalnum 690
isalpha 690
iscntrl 690
isdigit 690
isgraph 691
islower 691
ispunct 691
isspace 691
isupper 692
isxdigit 692
toupper 692
tolower 692
ANSI C Math Library 693
Library Functions 693
acos 693
asin 694
atan 694
atan2 694
ceil 694
cos 695
cosh 695
exp 695
fabs 695
oor 69 5
frexp 696
ldexp 696
log 696
log10 696
modf 697
pow 697
sin 697
sinh 697
sqrt 698
tan 698
tanh 698
ANSI C Stdlib Library 699
Library Dependency Tree 699
Library Functions 699
abs 699
27
MikroElektronika
mikoC PRO for dsPIC
atof 700
atoi 700
atol 700
div 700
ldiv 701
uldiv 701
labs 701
max 701
min 702
rand 702
srand 702
xtoi 702
Div Structures 703
ANSI C String Library 704
Library Functions 704
memchr 704
memcmp 705
memcpy 705
memmove 705
memset 706
strcat 706
strchr 706
strcmp 707
strcpy 707
strlen 707
strncat 708
strncpy 708
strspn 708
strncmp 709
strstr 709
strcspn 710
strpbrk 710
strrchr 710
strtok 711
Miscellaneous Libraries 712
Button Library 712
Library Routines 712
strrchr 712
Conversions Library 714
Library Dependency Tree 714
Library Routines 714
ByteToStr 715
ShortToStr 715
WordToStr 716
IntToStr 716
LongToStr 717
MikroElektronika
28
mikroC PRO for dsPIC
LongWordToStr 717
FloatToStr 718
WordToStrWithZeros 719
IntToStrWithZeros 719
LongWordToStrWithZeros 720
LongIntToStrWithZeros 720
ByteToHex 721
ShortToHex 721
WordToHex 722
IntToHex 722
LongWordToHex 723
LongIntToHex 723
Dec2Bcd 724
Bcd2Dec 724
Dec2Bcd16 725
Bcd2Dec16 725
Rtrim 726
Ltrim 726
PrintOut Library 727
Library Dependency Tree 727
Library Routines 727
PrintOut 727
Setjmp Library 731
Library Routines 731
Setjmp 731
Longjmp 732
Library Example 732
Sprint Library 734
Library Dependency Tree 734
Functions 734
sprintf 734
sprintl 736
sprinti 736
Library Example 737
Time Library 738
Library Routines 738
Time_dateToEpoch 738
Time_epochToDate 739
Time_dateDiff 740
Library Example 741
Trigonometry Library 742
Library Routines 742
sinE3 742
cosE3 743
CHAPTER 10 744
Tutorials 744
29
MikroElektronika
mikoC PRO for dsPIC
Managing Project 744
Projects 744
New Project 745
New Project Wizard Steps 745
New Project 748
New Project Wizard Steps 748
Customizing Projects 752
Managing Project Group 752
Add/Remove Files from Project 752
Project Level Denes: 75 3
Add/Remove Files from Project 754
Project Level Denes: 75 5
Source Files 756
Managing Source Files 756
Creating new source le 756
Opening an existing le 756
Printing an open le 756
Saving le 756
Saving le under a different name 757
Closing le 757
Search Paths 757
Paths for Source Files (.c ) 758
Paths for Header Files (.h) 758
Edit Project 759
Source Files 760
Managing Source Files 760
Creating new source le 760
Opening an existing le 760
Printing an open le 760
Saving le 760
Saving le under a different name 761
Closing le 761
Search Paths 761
Paths for Source Files (.c ) 762
Paths for Header Files (.h ) 762
Clean Project Folder 763
Compilation 764
Output Files 764
Assembly View 764
Multiple Library Versions 765
Using Microchip MPLAB® IDE with mikroElektronika compilers 766
Debugging Your Code 766
Using MPLAB® ICD 2 Debugger 766
Using MPLAB® Simulator 773
MikroElektronika
30