™
mikroC PRO for PIC32
mikroC PRO for PIC32 is a full-featured C compiler for PIC32 MCUs
from Microchip. It is designed for developing, building and debugging
PIC32-based 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 PIC32
Table of Contents
CHAPTER 1 30
INTRODUCTION 30
Introduction to mikroC PRO for PIC32 31
Features 31
Where to Start 31
Software License Agreement 32
mikroElektronika Associates License Statement and Limited Warranty 32
IMPORTANT - READ CAREFULLY 32
LIMITED WARRANTY 32
HIGH RISK ACTIVITIES 33
GENERAL PROVISIONS 33
Technical Support 34
How to Register 34
Who Gets the License Key 34
How to Get License Key 34
After Receving the License Key 36
CHAPTER 2 38
mikroC PRO for PIC32 38
Environment 38
Main Menu Options 39
File 40
File Menu Options 40
Edit 41
Edit Menu Options 41
Find Text 42
Replace Text 42
Find In Files 43
Go To Line 43
Regular expressions option 43
View 44
View Menu Options 44
Project 46
Project Menu Options 46
Build 47
Build Menu Options 47
Run 48
Run Menu Options 48
Tools 49
Tools Menu Options 49
Help 50
Help Menu Options 50
MikroElektronika
2
mikroC PRO for PIC32
mikroC PRO for PIC32 IDE 51
IDE Overview 51
Code Editor 52
Editor Settings 52
Auto Save 53
Highlighter 53
Spelling 53
Comment Style 53
Code Folding 53
Code Assistant 54
Parameter Assistant 54
Bookmarks 54
Go to Line 54
Column Select Mode 55
Editor Colors 55
Auto Correct 56
Auto Complete (Code Templates) 57
Code Explorer 59
Routine List 60
Project Manager 60
Project Settings 62
Library Manager 63
Managing libraries using Package Manager 64
Routine List 65
Statistics 65
Memory Usage Windows 65
Variables 66
Used RAM Locations 66
SFR Locations 67
ROM Memory Usage 67
ROM Memory Constants 68
Functions 68
Functions Sorted By Name Chart 69
Functions Sorted By Size Chart 69
Functions Sorted By Addresses 70
Function Tree 70
Memory Summary 71
Messages Window 72
Quick Converter 73
Macro Editor 73
Image Preview 74
Toolbars 76
File Toolbar 77
Edit Toolbar 77
Advanced Edit Toolbar 78
3
MikroElektronika
mikoC PRO for PIC32
Find/Replace Toolbar 78
Project Toolbar 79
Build Toolbar 79
Debug Toolbar 80
Styles Toolbar 80
Tools Toolbar 81
View Toolbar 81
Layout Toolbar 82
Help Toolbar 82
Customizing IDE Layout 83
Docking Windows 83
Saving Layout 84
Auto Hide 84
Options 85
Code editor 85
Tools 85
Output settings 86
Integrated Tools 88
Active Comments Editor 88
ASCII Chart 89
EEPROM Editor 90
Graphic Lcd Bitmap Editor 91
HID Terminal 92
Interrupt Assistant 92
Lcd Custom Character 93
Seven Segment Editor 94
UDP Terminal 94
USART Terminal 95
Active Comments 96
New Active Comment 96
Renaming Active Comment 103
Deleting Active Comment 104
Export Project 105
Jump To Interrupt 106
Regular Expressions 107
Introduction 107
Simple matches 107
Escape sequences 107
Character classes 107
Metacharacters 108
Metacharacters - Line separators 108
Metacharacters - Predened classes 10 9
Metacharacters - Word boundaries 109
Metacharacters - Iterators 109
Metacharacters - Alternatives 110
Metacharacters - Subexpressions 110
MikroElektronika
4
mikroC PRO for PIC32
Metacharacters - Backreferences 110
Keyboard Shortcuts 111
CHAPTER 3 113
mikroC PRO for PIC32 Command Line Options 113
CHAPTER 4 115
mikroICD (In-Circuit Debugger) 115
Introduction 115
mikroICD Debugger Options 117
Debugger Options 117
mikroICD Debugger Example 118
mikroICD Debugger Windows 122
Debug Windows 122
Breakpoints Window 122
Watch Values Window 122
RAM Window 124
Stopwatch Window 124
EEPROM Watch Window 125
Code Watch Window 126
CHAPTER 5 127
Software Simulator Overview 127
Software Simulator 128
Software Simulator Debug Windows 129
Debug Windows 129
Breakpoints Window 129
Watch Values Window 129
RAM Window 131
Stopwatch Window 131
EEPROM Watch Window 132
Code Watch Window 133
Software Simulator Debugger Options 134
Debugger Options 134
CHAPTER 6 135
mikroC PRO for PIC32 Specics 13 5
ANSI Standard Issues 136
Divergence from the ANSI C Standard 136
C Language Extensions 136
Implementation-dened Behavior 136
Predened Globals and Constants 137
Predened project level denes 137
Accessing Individual Bits 138
sbit type 139
at keyword 140
bit type 140
5
MikroElektronika
mikoC PRO for PIC32
Interrupts 141
Conguring Interrupts 14 1
Single Vector Mode 141
Multi Vector Mode 141
Interrupt Priorities 142
Interrupts and Register Sets 142
Register Set Selection in Single Vector Mode 142
Interrupts and Register Sets 142
Interrupt Coding Requirements 142
Interrupt Service Routine 142
Function Calls from Interrupt 143
Interrupt Example 144
Linker Directives 145
Directive absolute 145
Directive org 146
Directive orgall 146
Directive funcorg 146
Indirect Function Calls 146
Built-in Routines 147
Lo 148
Hi 148
Higher 149
Highest 149
LoWord 150
HiWord 150
Delay_us 151
Delay_ms 151
Vdelay_ms 151
VDelay_Advanced_ms 152
Delay_Cyc 152
Delay_Cyc_Long 152
Clock_kHz 153
Clock_Mhz 153
Get_Fosc_kHz 153
Get_Fosc_Per_Cyc 154
KVA0_TO_KVA1 154
KVA1_TO_KVA0 154
KVA_TO_PA 155
PA_TO_KVA0 155
PA_TO_KVA1 155
CP0_GET 155
CP0_SET 156
EnableInterrupts 156
DisableInterrupts 156
Code Optimization 158
Constant folding 158
MikroElektronika
6
mikroC PRO for PIC32
Constant propagation 158
Copy propagation 158
Value numbering 158
"Dead code" ellimination 158
Stack allocation 158
Local vars optimization 158
Better code generation and local optimization 158
Single Static Assignment Optimization 159
Introduction 159
Proper Coding Recommendations 160
Asm code and SSA optimization 161
Debugging Notes 161
Warning Messages Enhancement 161
CHAPTER 7 162
PIC32 Specics 16 2
Types Efciency 16 3
Nested Calls Limitations 163
Variable, constant and routine alignment 163
Boot Start-up Initialization 163
PIC32 Memory Organization 164
PIC32MX Memory Layout 165
Virtual vs Physical Addresses 166
Memory Type Speciers 16 7
code 167
data 167
rx 167
sfr 167
Read Modify Write Problem 168
CHAPTER 8 172
mikroC PRO for PIC32 Language Reference 172
Lexical Elements Overview 175
Whitespace 176
Whitespace in Strings 176
Line Splicing with Backslash (\) 176
Comments 177
C comments 177
C++ comments 177
Nested comments 177
Tokens 178
Token Extraction Example 178
Constants 179
Integer Constants 179
Long and Unsigned Sufxes 17 9
Decimal 179
7
MikroElektronika
mikoC PRO for PIC32
Hexadecimal 180
Binary 180
Octal 180
Floating Point Constants 181
Character Constants 181
Escape Sequences 181
Disambiguation 182
String Constants 183
Line Continuation with Backslash 183
Enumeration Constants 184
Pointer Constants 184
Constant Expressions 185
Keywords 186
Identiers 18 7
Case Sensitivity 187
Uniqueness and Scope 188
Identier Examples 18 8
Punctuators 188
Brackets 188
Parentheses 189
Braces 189
Comma 189
Semicolon 190
Colon 190
Asterisk (Pointer Declaration) 190
Equal Sign 191
Pound Sign (Preprocessor Directive) 191
Concepts 192
Objects 192
Objects and Declarations 192
Lvalues 193
Rvalues 193
Scope and Visibility 193
Scope 193
Visibility 193
Name Spaces 194
Duration 195
Static Duration 195
Local Duration 195
Types 196
Type Categories 196
Fundamental Types 197
Arithmetic Types 197
Integral Types 197
MikroElektronika
8
mikroC PRO for PIC32
Floating-point Types 198
Enumerations 198
Enumeration Declaration 198
Anonymous Enum Type 199
Enumeration Scope 199
Void Type 200
Void Functions 200
Generic Pointers 200
Derived Types 200
Arrays 201
Array Declaration 201
Array Initialization 201
Arrays in Expressions 202
Multi-dimensional Arrays 202
Pointers 203
Pointer Declarations 203
Null Pointers 204
Function Pointers 204
Assign an address to a Function Pointer 204
Function Pointers 206
Assign an address to a Function Pointer 206
Pointer Arithmetic 207
Arrays and Pointers 207
Assignment and Comparison 208
Pointer Addition 209
Pointer Subtraction 210
Structures 210
Structure Declaration and Initialization 210
Incomplete Declarations 211
Untagged Structures and Typedefs 212
Anonymous Structures 212
Working with Structures 213
Assignment 213
Size of Structure 213
Structures and Functions 213
Structure Member Access 214
Accessing Nested Structures 215
Structure Uniqueness 215
Unions 216
Union Declaration 216
Size of Union 216
Union Member Access 216
Anonymous Unions 217
Anonymous Union Member Access 217
Bit Fields 218
9
MikroElektronika
mikoC PRO for PIC32
Bit Fields Declaration 218
Bit Fields Access 219
Types Conversions 219
Standard Conversions 220
Arithmetic Conversions 220
Pointer Conversions 221
Explicit Types Conversions (Typecasting) 221
Declarations 222
Declarations and Denitions 22 2
Declarations and Declarators 223
Linkage 223
Linkage Rules 224
Internal Linkage Rules 224
Storage Classes 224
Auto 225
Register 225
Static 225
Extern 225
Type Qualiers 226
Qualier const 226
Qualier volatile 226
Typedef Specier 226
asm Declaration 227
Accessing variables 227
Asm code and SSA optimization 228
Initialization 229
Automatic Initialization 229
Functions 230
Function Declaration 230
Function Prototypes 231
Function Denition 23 1
Functions reentrancy 232
Function Calls and Argument Conversions 232
Function Calls 232
Argument Conversions 233
Ellipsis (‘...’) Operator 234
Operators 235
Operators Precedence and Associativity 236
Arithmetic Operators 237
Arithmetic Operators Overview 237
Binary Arithmetic Operators 238
Unary Arithmetic Operators 238
Relational Operators 239
Relational Operators Overview 239
MikroElektronika
10
mikroC PRO for PIC32
Relational Operators in Expressions 239
Bitwise Operators 240
Bitwise Operators Overview 240
Logical Operations on Bit Level 240
Bitwise Shift Operators 241
Bitwise vs. Logical 241
Logical Operators 242
Logical Operators Overview 242
Logical Operations 242
Logical Expressions and Side Effects 242
Logical vs. Bitwise 243
Conditional Operator ? : 243
Conditional Operator Rules 243
Assignment Operators 244
Simple Assignment Operator 244
Compound Assignment Operators 244
Assignment Rules 244
Unary Operators 245
Unary Arithmetic Operators 245
Unary Logical Operator 246
Unary Bitwise Operator 246
Address and Indirection Operator 246
Sizeof Operator 247
Sizeof Applied to Expression 247
Sizeof Applied to Type 247
Expressions 248
Comma Expressions 248
Statements 249
Labeled Statements 249
Expression Statements 250
Selection Statements 250
If Statement 250
Nested If statements 250
Switch Statement 251
Nested switch 252
Iteration Statements (Loops) 252
While Statement 252
Do Statement 252
For Statement 253
Jump Statements 254
Break and Continue Statements 254
Break Statement 254
Continue Statement 254
11
MikroElektronika
mikoC PRO for PIC32
Goto Statement 255
Return Statement 255
Compound Statements (Blocks) 256
Preprocessor 256
Preprocessor Directives 256
Line Continuation with Backslash (\) 257
Macros 257
Dening Macros and Macro Expansions 25 7
Macros with Parameters 258
Undening Macros 25 9
File Inclusion 259
Explicit Path 260
Preprocessor Operators 261
Operator # 261
Operator ## 261
Conditional Compilation 262
Directives #if, #elif, #else, and #endif 262
Directives #ifdef and #ifndef 263
CHAPTER 9 264
mikroC PRO for PIC32 Libraries 264
Hardware Libraries 265
Standard ANSI C Libraries 266
Miscellaneous Libraries 266
Hardware Libraries 267
ADC Library 267
Library Routines 268
ADCx_Init 268
ADCx_Init_Advanced 268
ADCx_Get_Sample 269
ADCx_Read 269
Library Example 270
CANSPI Library 271
Library Dependency Tree 271
External dependencies of CANSPI Library 271
Library Routines 272
CANSPISetOperationMode 272
CANSPIGetOperationMode 273
CANSPIInitialize 273
CANSPISetBaudRate 275
CANSPISetMask 276
CANSPISetFilter 277
CANSPIRead 278
CANSPIWrite 279
CANSPI Constants 279
MikroElektronika
12
mikroC PRO for PIC32
CANSPI_OP_MODE Constants 279
CANSPI_CONFIG_FLAGS Constants 280
CANSPI_TX_MSG_FLAGS Constants 281
CANSPI_RX_MSG_FLAGS Constants 281
CANSPI_MASK Constants 282
CANSPI_FILTER Constants 282
Library Example 283
HW Connection 286
Compact Flash Library 287
Library Dependency Tree 287
External dependencies of Compact Flash Library 288
Library Routines 289
Cf_Init 290
Cf_Detect 291
Cf_Enable 291
Cf_Disable 291
Cf_Read_Init 292
Cf_Read_Byte 292
Cf_Write_Init 292
Cf_Write_Byte 293
Cf_Read_Sector 293
Cf_Write_Sector 293
Cf_Fat_Init 294
Cf_Fat_QuickFormat 294
Cf_Fat_Assign 295
Cf_Fat_Reset 296
Cf_Fat_Read 296
Cf_Fat_Rewrite 297
Cf_Fat_Append 297
Cf_Fat_Delete 297
Cf_Fat_Write 298
Cf_Fat_Set_File_Date 298
Cf_Fat_Get_File_Date 299
Cf_Fat_Get_File_Date_Modied 29 9
Cf_Fat_Get_File_Size 300
Cf_Fat_Get_Swap_File 300
Library Example 302
HW Connection 306
Epson S1D13700 Graphic Lcd Library 307
External dependencies of the Epson S1D13700 Graphic Lcd Library 307
Library Routines 308
S1D13700_Init 309
S1D13700_Write_Command 310
S1D13700_Write_Parameter 311
S1D13700_Read_Parameter 311
S1D13700_Fill 311
S1D13700_GrFill 312
13
MikroElektronika
mikoC PRO for PIC32
S1D13700_TxtFill 312
S1D13700_Display_GrLayer 312
S1D13700_Display_TxtLayer 313
S1D13700_Set_Cursor 313
S1D13700_Display_Cursor 314
S1D13700_Write_Char 314
S1D13700_Write_Text 315
S1D13700_Dot 315
S1D13700_Line 316
S1D13700_H_Line 316
S1D13700_V_Line 317
S1D13700_Rectangle 317
S1D13700_Box 318
S1D13700_Rectangle_Round_Edges 318
S1D13700_Rectangle_Round_Edges_Fill 319
S1D13700_Circle 319
S1D13700_Circle_Fill 320
S1D13700_Image 320
S1D13700_PartialImage 321
Flash Memory Library 322
Library Routines 322
Flash_Write_Word 323
Flash_Write_Row 323
Flash_Erase_Page 323
Graphic Lcd Library 324
Library Dependency Tree 324
External dependencies of Graphic Lcd Library 325
Glcd_Init 326
Glcd_Set_Side 328
Glcd_Set_X 328
Glcd_Set_Page 328
Glcd_Read_Data 329
Glcd_Write_Data 329
Glcd_Fill 330
Glcd_Dot 330
Glcd_Line 330
Glcd_V_Line 331
Glcd_H_Line 331
Glcd_Rectangle 332
Glcd_Rectangle_Round_Edges 332
Glcd_Rectangle_Round_Edges_Fill 333
Glcd_Box 333
Glcd_Circle 334
Glcd_Circle_Fill 334
Glcd_Set_Font 335
Glcd_Write_Char 336
Glcd_Write_Text 336
MikroElektronika
14
mikroC PRO for PIC32
Glcd_Image 337
Glcd_PartialImage 337
I²C Library 338
Library Routines 338
I2Cx_Init 338
I2Cx_Init_Advanced 339
I2Cx_Start 339
I2Cx_Restart 340
I2Cx_Is_Idle 340
I2Cx_Read 341
I2Cx_Write 341
I2Cx_Stop 342
Library Example 342
Keypad Library 344
External dependencies of Keypad Library 344
Library Routines 344
Keypad_Init 344
Keypad_Key_Press 345
Keypad_Key_Click 345
Library Example 346
HW Connection 347
Lcd Library 348
Library Dependency Tree 348
Keypad_Key_Click 348
Library Routines 348
Lcd_Init 349
Lcd_Out 350
Lcd_Out_Cp 350
Lcd_Chr 350
Lcd_Chr_Cp 351
Lcd_Cmd 351
Available Lcd Commands 351
Library Example 352
Manchester Code Library 354
External dependencies of Manchester Code Library 354
Library Routines 355
Man_Receive_Init 355
Man_Receive 356
Man_Send_Init 356
Man_Send 357
Man_Synchro 357
Man_Break 358
Library Example 359
Connection Example 361
Memory Manager Library 362
Library Routines 362
15
MikroElektronika
mikoC PRO for PIC32
Heap_Init 362
malloc 362
free 363
LargestFreeMemBlock 363
TotalFreeMemSize 363
Multi Media Card Library 364
Secure Digital Card 364
Secure Digital High Capacity Card 364
Library Dependency Tree 365
External dependencies of MMC Library 365
Library Routines 365
Mmc_Init 366
Mmc_Read_Sector 367
Mmc_Write_Sector 367
Mmc_Read_Cid 368
Mmc_Read_Csd 368
Mmc_Fat_Init 369
Mmc_Fat_QuickFormat 370
Mmc_Fat_Assign 371
Mmc_Fat_Reset 372
Mmc_Fat_Read 372
Mmc_Fat_Rewrite 373
Mmc_Fat_Append 373
Mmc_Fat_Delete 373
Mmc_Fat_Write 374
Mmc_Fat_Set_File_Date 374
Mmc_Fat_Get_File_Date 375
Mmc_Fat_Get_File_Date_Modied 37 6
Mmc_Fat_Get_File_Size 376
Mmc_Fat_Get_Swap_File 377
Library Example 378
HW Connection 382
OneWire Library 383
Library Routines 383
Ow_Reset 383
Ow_Read 384
Ow_Write 384
Port Expander Library 385
Library Dependency Tree 385
External dependencies of Port Expander Library 385
Library Routines 385
Expander_Init 386
Expander_Init_Advanced 387
Expander_Read_Byte 388
Expander_Write_Byte 388
Expander_Read_PortA 388
MikroElektronika
16
mikroC PRO for PIC32
Expander_Read_PortB 389
Expander_Read_PortAB 389
Expander_Write_PortA 390
Expander_Write_PortB 390
Expander_Write_PortAB 391
Expander_Set_DirectionPortA 391
Expander_Set_DirectionPortB 392
Expander_Set_DirectionPortAB 392
Expander_Set_PullUpsPortA 392
Expander_Set_PullUpsPortB 393
Expander_Set_PullUpsPortAB 393
Library Example 394
HW Connection 395
PS/2 Library 396
External dependencies of PS/2 Library 396
Library Routines 396
Ps2_Cong 39 7
Ps2_Key_Read 397
Special Function Keys 398
Library Example 399
HW Connection 400
PWM Library 400
Library Routines 400
PWM_Init 401
PWM_Init_Advanced 401
PWM_Set_Duty 402
PWM_Start 402
PWM_Stop 402
Library Example 403
HW Connection 404
RS-485 Library 405
Library Dependency Tree 405
External dependencies of RS-485 Library 405
Library Routines 406
RS485Master_Init 406
RS485Master_Receive 407
RS485Master_Send 407
RS485Slave_Init 408
RS485Slave_Receive 409
RS485Slave_Send 409
Library Example 410
HW Connection 413
Message format and CRC calculations 414
Software I²C Library 415
External dependencies of Software I²C Library 415
Library Routines 415
17
MikroElektronika
mikoC PRO for PIC32
Soft_I2C_Init 416
Soft_I2C_Start 416
Soft_I2C_Read 417
Soft_I2C_Write 417
Soft_I2C_Stop 417
Soft_I2C_Break 418
Library Example 419
Software SPI Library 421
External dependencies of Software SPI Library 421
Library Routines 421
Soft_SPI_Init 422
Soft_SPI_Read 423
Soft_SPI_Write 423
Library Example 423
Software UART Library 425
Library Routines 425
Soft_UART_Init 425
Soft_UART_Read 426
Soft_UART_Write 426
Soft_UART_Break 427
Library Example 428
Sound Library 430
Library Routines 430
Sound_Init 430
Sound_Play 430
HW Connection 432
SPI Library 433
Library Routines 433
SPIx_Init 434
SPIx_Init_Advanced 435
SPIx_Read 437
SPIx_Write 437
SPI_Set_Active 438
Library Example 438
HW Connection 440
SPI Ethernet Library 441
Library Dependency Tree 441
External dependencies of SPI Ethernet Library 442
Library Routines 443
SPI_Ethernet_Init 443
SPI_Ethernet_Enable 445
SPI_Ethernet_Disable 446
SPI_Ethernet_doPacket 447
SPI_Ethernet_putByte 447
SPI_Ethernet_putBytes 448
SPI_Ethernet_putConstBytes 448
MikroElektronika
18
mikroC PRO for PIC32
SPI_Ethernet_putString 448
SPI_Ethernet_putConstString 449
SPI_Ethernet_getByte 449
SPI_Ethernet_getBytes 449
SPI_Ethernet_UserTCP 450
SPI_Ethernet_UserUDP 451
SPI_Ethernet_getIpAddress 452
Ethernet_getGwIpAddress 452
SPI_Ethernet_getDnsIpAddress 452
SPI_Ethernet_getIpMask 453
SPI_Ethernet_confNetwork 453
SPI_Ethernet_arpResolve 454
SPI_Ethernet_sendUDP 454
SPI_Ethernet_dnsResolve 455
SPI_Ethernet_initDHCP 456
SPI_Ethernet_doDHCPLeaseTime 456
SPI_Ethernet_renewDHCP 457
Library Example 458
HW Connection 465
SPI Ethernet ENC24J600 Library 466
Library Dependency Tree 466
External dependencies of SPI Ethernet ENC24J600 Library 467
Library Routines 468
SPI_Ethernet_24j600_Init 469
SPI_Ethernet_24j600_Enable 471
SPI_Ethernet_24j600_Disable 472
SPI_Ethernet_24j600_doPacket 473
SPI_Ethernet_24j600_putByte 473
SPI_Ethernet_24j600_putBytes 474
SPI_Ethernet_24j600_putConstBytes 474
SPI_Ethernet_24j600_putString 475
SPI_Ethernet_24j600_putConstString 475
SPI_Ethernet_24j600_getByte 475
SPI_Ethernet_24j600_getBytes 476
SPI_Ethernet_24j600_UserTCP 476
SPI_Ethernet_24j600_UserUDP 477
SPI_Ethernet_24j600_getIpAddress 477
SPI_Ethernet_24j600_getGwIpAddress 478
SPI_Ethernet_24j600_getDnsIpAddress 478
SPI_Ethernet_24j600_getIpMask 479
SPI_Ethernet_24j600_confNetwork 479
SPI_Ethernet_24j600_arpResolve 480
SPI_Ethernet_24j600_sendUDP 480
SPI_Ethernet_24j600_dnsResolve 481
SPI_Ethernet_24j600_initDHCP 482
SPI_Ethernet_24j600_doDHCPLeaseTime 483
SPI_Ethernet_24j600_renewDHCP 483
19
MikroElektronika
mikoC PRO for PIC32
SPI Graphic Lcd Library 484
Library Dependency Tree 484
External dependencies of SPI Lcd Library 484
Library Routines 484
SPI_Glcd_Init 485
SPI_Glcd_Set_Side 486
SPI_Glcd_Set_Page 486
SPI_Glcd_Set_X 486
SPI_Glcd_Read_Data 487
SPI_Glcd_Write_Data 487
SPI_Glcd_Fill 488
SPI_Glcd_Dot 488
SPI_Glcd_Line 489
SPI_Glcd_V_Line 489
SPI_Glcd_H_Line 490
SPI_Glcd_Rectangle 490
SPI_Glcd_Rectangle_Round_Edges 491
SPI_Glcd_Rectangle_Round_Edges_Fill 491
SPI_Glcd_Box 492
SPI_Glcd_Circle 492
SPI_Glcd_Circle_FIll 493
SPI_Glcd_Set_Font 494
SPI_Glcd_Write_Char 495
SPI_Glcd_Write_Text 495
SPI_Glcd_Image 496
SPI_Glcd_PartialImage 496
Library Example 497
HW Connection 499
SPI Lcd Library 500
Library Dependency Tree 500
External dependencies of SPI Lcd Library 500
Library Routines 500
SPI_Lcd_Cong 50 1
SPI_Lcd_Out 501
SPI_Lcd_Out_Cp 502
SPI_Lcd_Chr 502
SPI_Lcd_Chr_Cp 502
SPI_Lcd_Cmd 503
Available SPI Lcd Commands 503
Library Example 504
Default Pin Conguration 50 4
SPI Lcd8 (8-bit interface) Library 506
Library Dependency Tree 506
External dependencies of SPI Lcd Library 506
Library Routines 506
SPI_Lcd8_Cong 50 7
MikroElektronika
20
mikroC PRO for PIC32
SPI_Lcd8_Out 508
SPI_Lcd8_Out_Cp 508
SPI_Lcd8_Chr 508
SPI_Lcd8_Chr_Cp 509
SPI_Lcd8_Cmd 509
Available SPI Lcd8 Commands 510
Library Example 510
SPI T6963C Graphic Lcd Library 513
Library Dependency Tree 513
External dependencies of SPI T6963C Graphic Lcd Library 513
Library Routines 514
SPI_T6963C_cong 51 5
SPI_T6963C_writeData 516
SPI_T6963C_writeCommand 516
SPI_T6963C_setPtr 517
SPI_T6963C_waitReady 517
SPI_T6963C_ll 51 7
SPI_T6963C_dot 518
SPI_T6963C_write_char 518
SPI_T6963C_write_text 519
SPI_T6963C_line 520
SPI_T6963C_rectangle 520
SPI_T6963C_rectangle_round_edges 521
SPI_T6963C_rectangle_round_edges_ll 52 1
SPI_T6963C_box 522
SPI_T6963C_circle 522
SPI_T6963C_circle_ll 52 2
SPI_T6963C_image 523
SPI_T6963C_PartialImage 523
SPI_T6963C_sprite 524
SPI_T6963C_set_cursor 524
SPI_T6963C_clearBit 524
SPI_T6963C_setBit 525
SPI_T6963C_negBit 525
SPI_T6963C_displayGrPanel 525
SPI_T6963C_displayTxtPanel 526
SPI_T6963C_setGrPanel 526
SPI_T6963C_setTxtPanel 526
SPI_T6963C_panelFill 527
SPI_T6963C_grFill 527
SPI_T6963C_txtFill 527
SPI_T6963C_cursor_height 528
SPI_T6963C_graphics 528
SPI_T6963C_text 528
SPI_T6963C_cursor 529
SPI_T6963C_cursor_blink 529
Library Example 529
21
MikroElektronika
mikoC PRO for PIC32
HW Connection 535
T6963C Graphic Lcd Library 536
Library Dependency Tree 536
External dependencies of T6963C Graphic Lcd Library 537
Library Routines 538
T6963C_init 539
T6963C_writeData 540
T6963C_writeCommand 541
T6963C_setPtr 541
T6963C_waitReady 541
T6963C_ll 54 2
T6963C_dot 542
T6963C_write_char 543
T6963C_write_text 544
T6963C_line 544
T6963C_rectangle 545
T6963C_rectangle_round_edges 545
T6963C_rectangle_round_edges_ll 54 6
T6963C_box 546
T6963C_circle 546
T6963C_circle_ll 54 7
T6963C_image 547
T6963C_PartialImage 548
T6963C_sprite 548
T6963C_set_cursor 549
T6963C_clearBit 549
T6963C_setBit 549
T6963C_negBit 550
T6963C_displayGrPanel 550
T6963C_displayTxtPanel 550
T6963C_setGrPanel 551
T6963C_setTxtPanel 551
T6963C_panelFill 551
T6963C_grFill 552
T6963C_txtFill 552
T6963C_cursor_height 552
T6963C_graphics 553
T6963C_text 553
T6963C_cursor 553
T6963C_cursor_blink 554
Library Example 554
HW Connection 560
TFT Library 561
External dependencies of TFT Library 561
Library Routines 562
TFT_Init 563
MikroElektronika
22
mikroC PRO for PIC32
TFT_Set_Index 564
TFT_Write_Command 564
TFT_Write_Data 564
TFT_Set_Active 565
TFT_Set_Font 566
TFT_Write_Char 567
TFT_Write_Text 567
TFT_Fill_Screen 568
TFT_Dot 569
TFT_Set_Pen 570
TFT_Set_Brush 571
TFT_Line 573
TFT_H_Line 574
TFT_V_Line 574
TFT_Rectangle 574
TFT_Rectangle_Round_Edges 575
TFT_Circle 575
TFT_Image 575
TFT_Partial_Image 576
TFT_Image_Jpeg 576
TFT_RGBToColor16bit 577
TFT_Color16bitToRGB 577
HW Connection 578
Touch Panel Library 579
Library Dependency Tree 579
External dependencies of Touch Panel Library 579
Library Routines 579
TP_Init 580
TP_Set_ADC_Threshold 580
TP_Press_Detect 581
TP_Get_Coordinates 582
TP_Calibrate_Bottom_Left 582
TP_Calibrate_Upper_Right 582
TP_Get_Calibration_Consts 583
TP_Set_Calibration_Consts 583
Touch Panel TFT Library 584
Library Dependency Tree 584
External dependencies of Touch Panel TFT Library 584
Library Routines 584
TP_TFT_Init 585
TP_TFT_Set_ADC_Threshold 585
TP_TFT_Press_Detect 586
TP_TFT_Get_Coordinates 587
TP_TFT_Calibrate_Min 587
TP_TFT_Calibrate_Max 587
TP_TFT_Get_Calibration_Consts 588
23
MikroElektronika
mikoC PRO for PIC32
TP_TFT_Set_Calibration_Consts 588
HW Connection 589
UART Library 590
Library Routines 590
UARTx_Init 591
UARTx_Init_Advanced 592
UARTx_Data_Ready 593
UARTx_Tx_Idle 593
UARTx_Read 594
UARTx_Read_Text 595
UARTx_Write 596
UARTx_Write_Text 596
UART_Set_Active 597
Library Example 598
HW Connection 599
USB Library 600
USB HID Class 600
Descriptor File 600
Library Routines 600
HID_Enable 601
HID_Read 601
HID_Write 601
HID_Disable 602
USB_Interrupt_Proc 602
USB_Polling_Proc 603
Gen_Enable 603
Gen_Read 604
Gen_Write 604
Library Example 605
HW Connection 605
Standard ANSI C Libraries 606
ANSI C Ctype Library 606
Library Functions 606
isalnum 607
isalpha 607
iscntrl 607
isdigit 607
isgraph 607
islower 608
ispunct 608
isspace 608
isupper 608
isxdigit 608
toupper 609
tolower 609
ANSI C Math Library 610
MikroElektronika
24
mikroC PRO for PIC32
Library Functions 610
acos 610
asin 611
atan 611
atan2 611
ceil 611
cos 611
cosh 612
exp 612
fabs 612
oor 61 2
frexp 612
ldexp 613
log 613
log10 613
modf 613
pow 613
sin 614
sinh 614
sqrt 614
tan 614
tanh 614
ANSI C Stdlib Library 615
Library Dependency Tree 615
Library Functions 615
abs 615
atof 616
atoi 616
atol 616
div 616
ldiv 617
uldiv 617
labs 617
max 617
min 618
rand 618
srand 618
xtoi 618
Div Structures 619
ANSI C String Library 620
Library Functions 620
memchr 620
memcmp 621
memcpy 621
memmove 621
memset 622
strcat 622
25
MikroElektronika
mikoC PRO for PIC32
strchr 622
strcmp 623
strcpy 623
strlen 623
strncat 624
strncpy 624
strspn 624
strncmp 625
strstr 625
strcspn 625
strpbrk 626
strrchr 626
strtok 627
Miscellaneous Libraries 628
Button Library 628
Library Routines 628
Button 628
Conversions Library 630
Library Dependency Tree 630
Library Routines 630
ByteToStr 631
ShortToStr 631
WordToStr 632
IntToStr 632
LongToStr 633
LongWordToStr 633
FloatToStr 634
WordToStrWithZeros 634
IntToStrWithZeros 635
LongWordToStrWithZeros 635
LongIntToStrWithZeros 636
ByteToHex 636
ShortToHex 637
WordToHex 637
IntToHex 638
LongWordToHex 638
LongIntToHex 639
Dec2Bcd 639
Bcd2Dec 640
Dec2Bcd16 640
Bcd2Dec16 640
Rtrim 641
Ltrim 641
PrintOut Library 642
Library Dependency Tree 642
Library Routines 642
MikroElektronika
26
mikroC PRO for PIC32
PrintOut 642
Setjmp Library 646
Library Routines 646
Setjmp 646
Longjmp 647
Library Example 647
Sprint Library 649
Library Dependency Tree 649
Functions 649
sprintf 649
sprintl 651
sprinti 651
Library Example 652
Time Library 653
Library Routines 653
Time_dateToEpoch 653
Time_epochToDate 654
Time_dateDiff 654
Library Example 655
Trigonometry Library 656
Library Routines 656
sinE3 656
cosE3 656
CHAPTER 10 657
Tutorials 657
Managing Project 657
Projects 657
New Project 658
New Project Wizard Steps 658
New Project 661
New Project Wizard Steps 661
Customizing Projects 665
Managing Project Group 665
Add/Remove Files from Project 665
Project Level Denes: 66 6
Add/Remove Files from Project 667
Project Level Denes: 66 8
Source Files 669
Managing Source Files 669
Creating new source le 669
Opening an existing le 669
Printing an open le 669
Saving le 669
Saving le under a different name 670
27
MikroElektronika
mikoC PRO for PIC32
Closing le 67 0
Search Paths 670
Paths for Source Files (.c ) 671
Paths for Header Files (.h) 671
Edit Project 672
Source Files 673
Managing Source Files 673
Creating new source le 673
Opening an existing le 673
Printing an open le 673
Saving le 673
Saving le under a different name 674
Closing le 674
Search Paths 674
Paths for Source Files (.c ) 675
Paths for Header Files (.h ) 675
Clean Project Folder 676
Compilation 677
Output Files 677
Assembly View 677
Creating New Library 678
Multiple Library Versions 678
Frequently Asked Questions 679
Can I use your compilers and programmer on Windows Vista (Windows 7) ? 679
I am getting “Access is denied” error in Vista, how to solve this problem ? 679
What are differences between mikroC PRO, mikroPascal PRO and mikroC PRO compilers ? Why
do they have different prices ? 679
Why do your PIC compilers don’t support 12F508 and some similar chips ? 679
What are limitations of demo versions of mikroElektronika’s compilers ? 679
Why do I still get demo limit error when I purchased and installed license key ? 679
I have bought license for the older version, do I have to pay license for the new version of the compiler ? 680
Do your compilers work on Windows Vista (Windows 7) ? 680
What does this function/procedure/routine do ? 680
I try to compile one of the provided examples and nothing happens, what is the problem? 680
Can I get your library sources ? I need to provide all sources with my project. 680
Can I use code I developed in your compilers in commercial purposes ? Are there some limitations
? 680
Why does an example provided with your compilers doesn’t work ? 680
Your example works if I use the same MCU you did, but how to make it work for another MCU ? 680
I need this project nished, can you help me ? 68 1
Do you have some discount on your compilers/development systems for students/professors ? 681
I have a question about your compilers which is not listed here. Where can I nd an answer ? 68 1
MikroElektronika
28
mikroC PRO for PIC32
29
MikroElektronika
mikoC PRO for PIC32
CHAPTER 1
INTRODUCTION
The mikroC PRO for PIC32 is a powerful, feature-rich development tool for PIC32 microcontrollers. It is designed to
provide the programmer with the easiest possible solution to developing applications for embedded systems, without
compromising performance or control.
mikroC PRO for PIC32 IDE
MikroElektronika
30