mikroPascal PRO for dsPIC
mikroPascal PRO for dsPIC30/33 and PIC24 is a full-featured 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
mikoPascal PRO for dsPIC30/33 and PIC24
Table of Contents
CHAPTER 1 32
INTRODUCTION 32
Introduction to mikroPascal PRO for dsPIC30/33 and PIC24 33
Features 33
Where to Start 33
What’s new in mikroPascal 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
mikroPascal 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
mikroPascal PRO for dsPIC30/33 and PIC24
Help 53
Help Menu Options 53
mikroPascal 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
Routine List 68
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
3
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
File Toolbar 80
Edit Toolbar 80
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
MikroElektronika
4
mikroPascal PRO for dsPIC30/33 and PIC24
Metacharacters - Iterators 112
Metacharacters - Alternatives 113
Metacharacters - Subexpressions 113
Metacharacters - Backreferences 113
Keyboard Shortcuts 114
CHAPTER 3 116
mikroPascal 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
mikroPascal PRO for dsPIC30/33 and PIC24 Specics 13 8
GOTO Table 139
Predened Globals and Constants 140
Predened project level denes 140
Accessing Individual Bits 141
sbit type 142
at keyword 143
bit type 143
5
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Interrupts 144
Function Calls from Interrupt 144
Interrupt Handling 144
Interrupt Example 145
Linker Directives 146
Directive absolute 146
Directive org 146
Directive orgall 147
Built-in Routines 148
Lo 149
Hi 149
Higher 150
Highest 150
LoWord 151
HiWord 151
Inc 152
Dec 152
Chr 152
Ord 153
SetBit 153
ClearBit 153
TestBit 154
Delay_us 154
Delay_ms 154
Vdelay_ms 155
VDelay_advanced_ms 155
Delay_Cyc 156
Delay_Cyc_Long 156
Clock_kHz 156
Clock_MHz 157
Get_Fosc_kHz 157
Get_Fosc_Per_Cyc 157
Reset 158
ClrWdt 158
DisableContextSaving() 158
SetFuncCall 159
SetOrg 159
GetDateTime 160
DoGetVersion 160
Code Optimization 161
Constant folding 161
Constant propagation 161
Copy propagation 161
Value numbering 161
"Dead code" ellimination 161
Stack allocation 161
MikroElektronika
6
mikroPascal PRO for dsPIC30/33 and PIC24
Local vars optimization 161
Better code generation and local optimization 161
Single Static Assignment Optimization 162
Introduction 162
Proper Coding Recommendations 163
Asm code and SSA optimization 164
Debugging Notes 164
Warning Messages Enhancement 164
Common Object File Format (COFF) 165
COFF File Format 165
COFF File Generation 165
CHAPTER 7 167
dsPIC30/33 and PIC24 Specics 16 7
Types Efciency 16 8
Nested Calls Limitations 168
Limits of Indirect Approach Through PSV 168
Limits of Pointer to Function 168
Variable, constant and routine alignment 168
dsPIC Memory Organization 169
Program Memory (ROM) 169
Data Memory (RAM) 170
SFR Memory Space 170
X and Y Data RAM 170
DMA RAM 171
Unimplemented Memory Space 171
Memory Type Speciers 17 2
code 172
data 172
rx 172
sfr 172
xdata 173
ydata 173
dma 173
Memory Type Qualiers 174
Near Memory Qualier 174
Far Memory Qualier 174
Read Modify Write Problem 175
CHAPTER 8 179
mikroPascal PRO for dsPIC30/33 and PIC24 Language Reference 179
Lexical Elements Overview 181
Whitespace 182
Newline Character 182
Whitespace in Strings 182
Comments 183
7
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Tokens 183
Token Extraction Example 184
Literals 184
Integer Literals 184
Floating Point Literals 185
Character Literals 185
String Literals 185
Keywords 187
Identiers 19 0
Case Sensitivity 190
Uniqueness and Scope 190
Identier Examples 19 0
Punctuators 190
Brackets 191
Parentheses 191
Comma 191
Semicolon 191
Colon 192
Dot 192
Program Organization 192
Organization of Main Module 192
Organization of Other Units 193
Scope and Visibility 194
Scope 194
Visibility 195
Name Spaces 195
Units 196
Uses Clause 196
Main Unit 196
Other Units 197
Variables 198
External Modier 19 8
Variables and dsPIC30/33 and PIC24 199
Constants 200
Labels 200
Functions and Procedures 201
Functions 201
Procedures 202
Forward declaration 203
Functions reentrancy 204
Types 204
Type Categories 204
Simple Types 205
Derived Types 205
MikroElektronika
8
mikroPascal PRO for dsPIC30/33 and PIC24
Arrays 205
Array Declaration 205
Constant Arrays 206
Multi-dimensional Arrays 206
Strings 207
String Concatenating 207
Pointers 208
Pointers and memory spaces 209
Function Pointers 209
@ Operator 210
Pointer Arithmetic 211
Assignment and Comparison 211
Pointer Addition 212
Pointer Subtraction 212
Records 213
Accessing Fields 214
Types Conversions 215
Implicit Conversion 215
Explicit Conversion 216
Conversions Examples 216
Typedef Specier 217
Type Qualiers 217
Qualier const 217
Qualier volatile 217
Operators 218
Operators Precedence and Associativity 218
Arithmetic Operators 218
Division by Zero 219
Unary Arithmetic Operators 219
Relational Operators 219
Relational Operators Overview 219
Relational Operators in Expressions 219
Bitwise Operators 220
Bitwise Operators Overview 220
Logical Operations on Bit Level 220
Unsigned and Conversions 221
Signed and Conversions 221
Bitwise Shift Operators 221
Boolean Operators 222
Unary Operators 222
Unary Arithmetic Operator 222
Unary Bitwise Operator 222
Address and Indirection Operator 223
Sizeof Operator 223
9
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Sizeof Applied to Expression 223
Sizeof Applied to Type 223
Expressions 224
Expression Evaluation 224
Statements 225
Assignment Statements 226
Compound Statements (Blocks) 226
Conditional Statements 226
If Statement 227
Nested if statements 227
Case Statement 227
Nested Case Statements 228
Iteration Statements 229
For Statement 229
Endless Loop 229
While Statement 230
Repeat Statement 230
Jump Statements 231
Break and Continue Statements 231
Break Statement 231
Continue Statement 231
Exit Statement 232
Goto Statement 232
asm Statement 233
Accessing variables 233
Asm code and SSA optimization 234
With Statement 234
Directives 235
Compiler Directives 235
Directives #DEFINE and #UNDEFINE 235
Directives #IFDEF, #IFNDEF, #ELSE and #ENDIF 235
Include Directive $I 236
Linker Directives 237
Directive absolute 237
Directive org 237
CHAPTER 9 239
mikroPascal PRO for dsPIC30/33 and PIC24 Libraries 239
Hardware Libraries 240
Digital Signal Processing Libraries 240
Miscellaneous Libraries 241
Hardware Libraries 242
ADC Library 242
MikroElektronika
10
mikroPascal PRO for dsPIC30/33 and PIC24
Library Routines 243
ADCx_Init 243
ADCx_Init_Advanced 244
ADCx_Get_Sample 245
ADCx_Read 245
ADC_Set_Active 246
Library Example 246
HW Connection 247
CAN Library 248
Library Routines 248
CANxSetOperationMode 249
CANxGetOperationMode 249
CANxInitialize 250
CANxSetBaudRate 251
CANxSetMask 252
CANxSetFilter 253
CANxRead 254
CANxWrite 255
CAN Constants 256
CAN_OP_MODE Constants 256
CAN_CONFIG_FLAGS Constants 256
CAN_TX_MSG_FLAGS Constants 257
CAN_RX_MSG_FLAGS Constants 258
CAN_MASK Constants 258
CAN_FILTER Constants 259
Library Example 259
HW Connection 262
CANSPI Library 263
Library Dependency Tree 263
External dependencies of CANSPI Library 264
Library Routines 264
CANSPISetOperationMode 264
CANSPIGetOperationMode 265
CANSPIInit 265
CANSPISetBaudRate 267
CANSPISetMask 268
CANSPISetFilter 269
CANSPIRead 270
CANSPIWrite 271
CANSPI Constants 271
CANSPI_OP_MODE Constants 271
CANSPI_TX_MSG_FLAGS Constants 273
CANSPI_RX_MSG_FLAGS Constants 273
CANSPI_MASK Constants 274
CANSPI_FILTER Constants 274
Library Example 275
HW Connection 278
11
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Compact Flash Library 279
Library Dependency Tree 279
External dependencies of Compact Flash Library 280
Library Routines 281
Cf_Init 282
Cf_Detect 283
Cf_Enable 283
Cf_Disable 283
Cf_Read_Init 284
Cf_Read_Byte 284
Cf_Write_Init 284
Cf_Write_Byte 285
Cf_Read_Sector 285
Cf_Write_Sector 285
Cf_Fat_Init 286
Cf_Fat_QuickFormat 286
Cf_Fat_Assign 287
Cf_Fat_Reset 288
Cf_Fat_Read 288
Cf_Fat_Rewrite 289
Cf_Fat_Append 289
Cf_Fat_Delete 289
Cf_Fat_Write 290
Cf_Fat_Set_File_Date 290
Cf_Fat_Get_File_Date 291
Cf_Fat_Get_File_Date_Modied 29 1
Cf_Fat_Get_File_Size 292
Cf_Fat_Get_Swap_File 292
Library Example 294
HW Connection 299
ECAN Library 300
Library Routines 300
ECANxDmaChannelInit 301
ECANxSetOperationMode 301
ECANxGetOperationMode 302
ECANxInitialize 303
ECANxSelectTxBuffers 304
ECANxFilterDisable 304
ECANxFilterEnable 305
ECANxSetBufferSize 305
ECANxSetBaudRate 306
ECANxSetMask 307
ECANxSetFilter 308
ECANxRead 309
ECANxWrite 310
ECAN Constants 311
MikroElektronika
12
mikroPascal PRO for dsPIC30/33 and PIC24
ECAN_OP_MODE Constants 311
ECAN_CONFIG_FLAGS Constants 311
ECAN_TX_MSG_FLAGS Constants 312
ECAN_RX_MSG_FLAGS Constants 312
ECAN_MASK Constants 313
ECAN_FILTER Constants 313
ECAN_RX_BUFFER Constants 314
Library Example 315
HW Connection 319
EEPROM Library 319
Library Routines 319
EEPROM_Erase 320
EEPROM_Erase_Block 320
EEPROM_Read 320
EEPROM_Write 321
EEPROM_Write_Block 321
Library Example 321
Epson S1D13700 Graphic Lcd Library 323
External dependencies of the Epson S1D13700 Graphic Lcd Library 323
Library Routines 324
S1D13700_Init 325
S1D13700_Write_Command 326
S1D13700_Write_Parameter 327
S1D13700_Read_Parameter 327
S1D13700_Fill 327
S1D13700_GrFill 328
S1D13700_TxtFill 328
S1D13700_Display_GrLayer 328
S1D13700_Display_TxtLayer 329
S1D13700_Set_Cursor 329
S1D13700_Display_Cursor 330
S1D13700_Write_Char 330
S1D13700_Write_Text 331
S1D13700_Dot 331
S1D13700_Line 332
S1D13700_H_Line 332
S1D13700_V_Line 333
S1D13700_Rectangle 333
S1D13700_Box 334
S1D13700_Rectangle_Round_Edges 334
S1D13700_Rectangle_Round_Edges_Fill 335
S1D13700_Circle 335
S1D13700_Circle_Fill 336
S1D13700_Image 336
S1D13700_PartialImage 337
Flash Memory Library 338
13
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
dsPIC30: 338
PIC24 and dsPIC33: 338
24F04KA201 and 24F16KA102 Family Specics: 33 9
Library Routines 339
dsPIC30 Functions 339
PIC24 and dsPIC33 Functions 339
dsPIC30 Functions 340
FLASH_Erase32 340
FLASH_Write_Block 340
FLASH_Write_Compact 341
FLASH_Write_Init 341
FLASH_Write_Loadlatch4 342
FLASH_Write_Loadlatch4_Compact 343
FLASH_Write_DoWrite 344
FLASH_Read4 344
FLASH_Read4_Compact 345
PIC24 and dsPIC33 Functions 345
FLASH_Erase 345
FLASH_Write 346
FLASH_Write_Compact 346
FLASH_Read 347
FLASH_Read_Compact 347
Library Example 347
Graphic Lcd Library 349
External dependencies of Graphic Lcd Library 349
External dependencies of Graphic Lcd Library 350
Library Routines 351
Glcd_Init 351
Glcd_Set_Side 353
Glcd_Set_X 353
Glcd_Set_Page 353
Glcd_Read_Data 354
Glcd_Write_Data 354
Glcd_Fill 355
Glcd_Dot 355
Glcd_Line 355
Glcd_V_Line 356
Glcd_H_Line 356
Glcd_Rectangle 357
Glcd_Rectangle_Round_Edges 357
Glcd_Rectangle_Round_Edges_Fill 358
Glcd_Box 358
Glcd_Circle 359
Glcd_Circle_Fill 359
Glcd_Set_Font 360
Glcd_Write_Char 361
Glcd_Write_Text 361
MikroElektronika
14
mikroPascal PRO for dsPIC30/33 and PIC24
Glcd_Image 362
Glcd_PartialImage 362
Library Example 363
HW Connection 365
I²C Library 366
Library Routines 366
I2Cx_Init 366
I2Cx_Start 367
I2Cx_Restart 367
I2Cx_Is_Idle 368
I2Cx_Read 368
I2Cx_Write 369
I2Cx_Stop 369
Library Example 370
HW Connection 370
Keypad Library 371
External dependencies of Keypad Library 371
Library Routines 371
Keypad_Init 371
Keypad_Key_Press 372
Keypad_Key_Click 372
Library Example 373
HW Connection 374
Lcd Library 375
Library Dependency Tree 375
External dependencies of Lcd Library 375
Library Routines 375
Lcd_Init 376
Lcd_Out 377
Lcd_Out_Cp 377
Lcd_Chr 377
Lcd_Chr_Cp 378
Lcd_Cmd 378
Available Lcd Commands 378
Library Example 379
Manchester Code Library 381
External dependencies of Manchester Code Library 381
Library Routines 382
Man_Receive_Init 382
Man_Receive 383
Man_Send_Init 383
Man_Send 384
Man_Synchro 384
Man_Break 385
Library Example 386
Connection Example 388
15
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Multi Media Card Library 389
Secure Digital Card 389
Secure Digital High Capacity Card 389
Library Dependency Tree 390
External dependencies of MMC Library 390
Library Routines 390
Mmc_Init 391
Mmc_Read_Sector 392
Mmc_Write_Sector 392
Mmc_Read_Cid 393
Mmc_Read_Csd 393
Mmc_Fat_Init 394
Mmc_Fat_QuickFormat 395
Mmc_Fat_Assign 396
Mmc_Fat_Reset 397
Mmc_Fat_Read 397
Mmc_Fat_Rewrite 398
Mmc_Fat_Append 398
Mmc_Fat_Delete 398
Mmc_Fat_Write 399
Mmc_Fat_Set_File_Date 399
Mmc_Fat_Get_File_Date 400
Mmc_Fat_Get_File_Date_Modied 40 1
Mmc_Fat_Get_File_Size 401
Mmc_Fat_Get_Swap_File 402
Library Example 403
HW Connection 408
OneWire Library 409
Library Routines 409
Ow_Reset 409
Ow_Read 410
Ow_Write 410
Library Example 411
HW Connection 413
Peripheral Pin Select Library 414
Library Routines 414
Unlock_IOLOCK 414
Lock_IOLOCK 414
PPS_Mapping 415
Direction Parameters 415
Input Functions 415
Output Functions 416
Port Expander Library 418
Library Dependency Tree 418
External dependencies of Port Expander Library 418
Library Routines 418
MikroElektronika
16
mikroPascal PRO for dsPIC30/33 and PIC24
Expander_Init 419
Expander_Init_Advanced 420
Expander_Read_Byte 420
Expander_Write_Byte 421
Expander_Read_PortA 421
Expander_Read_PortB 422
Expander_Read_PortAB 422
Expander_Write_PortA 423
Expander_Write_PortB 423
Expander_Write_PortAB 424
Expander_Set_DirectionPortA 424
Expander_Set_DirectionPortB 425
Expander_Set_DirectionPortAB 425
Expander_Set_PullUpsPortA 425
Expander_Set_PullUpsPortB 426
Expander_Set_PullUpsPortAB 426
HW Connection 428
PS/2 Library 429
External dependencies of PS/2 Library 429
Library Routines 429
Ps2_Cong 43 0
Ps2_Key_Read 430
Special Function Keys 431
Library Example 432
HW Connection 433
PWM Library 433
Library Routines 433
PWM_Init 434
PWM_Set_Duty 434
PWM_Start 435
PWM_Stop 435
Library Example 435
HW Connection 437
PWM Motor Control Library 437
Library Routines 437
PWMx_Mc_Init 438
PWMx_Mc_Set_Duty 439
PWMx_Mc_Start 439
PWMx_Mc_Stop 440
HW Connection 441
RS-485 Library 441
Library Dependency Tree 442
External dependencies of RS-485 Library 442
Library Routines 442
RS485Master_Init 442
RS485Master_Receive 443
17
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
RS485Master_Send 443
RS485Slave_Init 444
RS485Slave_Receive 445
RS485Slave_Send 445
Library Example 446
HW Connection 449
Message format and CRC calculations 450
Software I²C Library 451
External dependencies of Software I²C Library 451
Library Routines 451
Soft_I2C_Init 452
Soft_I2C_Start 452
Soft_I2C_Read 453
Soft_I2C_Write 453
Soft_I2C_Stop 453
Soft_I2C_Break 454
Library Example 455
Software SPI Library 457
External dependencies of Software SPI Library 457
Library Routines 457
Soft_SPI_Init 458
Soft_SPI_Read 458
Soft_SPI_Write 459
Library Example 459
Software UART Library 461
Library Routines 461
Soft_UART_Init 461
Soft_UART_Read 462
Soft_UART_Write 462
Soft_UART_Break 463
Library Example 464
Sound Library 465
Library Routines 465
Sound_Init 465
Sound_Play 465
Library Example 466
HW Connection 468
SPI Library 469
Library Routines 469
SPIx_Init 470
SPIx_Init_Advanced 471
SPIx_Read 473
SPIx_Write 473
SPI_Set_Active 474
Library Example 474
HW Connection 475
MikroElektronika
18
mikroPascal PRO for dsPIC30/33 and PIC24
SPI Ethernet Library 476
Library Dependency Tree 476
External dependencies of SPI Ethernet Library 477
Library Routines 477
SPI_Ethernet_Init 478
SPI_Ethernet_Enable 480
SPI_Ethernet_Disable 481
SPI_Ethernet_doPacket 482
SPI_Ethernet_putByte 482
SPI_Ethernet_putBytes 483
SPI_Ethernet_putConstBytes 483
SPI_Ethernet_putString 484
SPI_Ethernet_putConstString 484
SPI_Ethernet_getByte 484
SPI_Ethernet_getBytes 485
SPI_Ethernet_UserTCP 485
SPI_Ethernet_UserUDP 486
SPI_Ethernet_setUserHandlers 486
SPI_Ethernet_getIpAddress 487
SPI_Ethernet_getGwIpAddress 487
SPI_Ethernet_getDnsIpAddress 488
SPI_Ethernet_getIpMask 488
SPI_Ethernet_confNetwork 489
SPI_Ethernet_arpResolve 490
SPI_Ethernet_sendUDP 490
SPI_Ethernet_dnsResolve 491
SPI_Ethernet_initDHCP 492
SPI_Ethernet_doDHCPLeaseTime 492
SPI_Ethernet_renewDHCP 493
Library Example 493
HW Connection 500
SPI Ethernet ENC24J600 Library 501
Library Dependency Tree 501
External dependencies of SPI Ethernet ENC24J600 Library 502
Library Routines 503
SPI_Ethernet_24j600_Init 504
SPI_Ethernet_24j600_Enable 506
SPI_Ethernet_24j600_Disable 507
SPI_Ethernet_24j600_doPacket 508
SPI_Ethernet_24j600_putByte 508
SPI_Ethernet_24j600_putBytes 509
SPI_Ethernet_24j600_putConstBytes 509
SPI_Ethernet_24j600_putString 510
SPI_Ethernet_24j600_putConstString 510
SPI_Ethernet_24j600_getByte 510
SPI_Ethernet_24j600_getBytes 511
19
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
SPI_Ethernet_24j600_UserTCP 511
SPI_Ethernet_24j600_UserUDP 512
SPI_Ethernet_24j600_setUserHandlers 512
SPI_Ethernet_24j600_getIpAddress 513
SPI_Ethernet_24j600_getGwIpAddress 513
SPI_Ethernet_24j600_getDnsIpAddress 513
SPI_Ethernet_24j600_getIpMask 514
SPI_Ethernet_24j600_confNetwork 514
SPI_Ethernet_24j600_arpResolve 515
SPI_Ethernet_24j600_sendUDP 515
SPI_Ethernet_24j600_dnsResolve 516
SPI_Ethernet_24j600_initDHCP 517
SPI_Ethernet_24j600_doDHCPLeaseTime 517
SPI_Ethernet_24j600_renewDHCP 518
Library Example 519
SPI Graphic Lcd Library 520
Library Dependency Tree 520
External dependencies of SPI Lcd Library 520
Library Routines 520
SPI_Glcd_Init 521
SPI_Glcd_Set_Side 522
SPI_Glcd_Set_Page 522
SPI_Glcd_Set_X 522
SPI_Glcd_Read_Data 523
SPI_Glcd_Write_Data 523
SPI_Glcd_Fill 523
SPI_Glcd_Dot 524
SPI_Glcd_Line 524
SPI_Glcd_V_Line 525
SPI_Glcd_H_Line 525
SPI_Glcd_Rectangle 526
SPI_Glcd_Rectangle_Round_Edges 526
SPI_Glcd_Rectangle_Round_Edges_Fill 527
SPI_Glcd_Box 527
SPI_Glcd_Circle 528
SPI_Glcd_Circle_FIll 528
SPI_Glcd_Set_Font 529
SPI_Glcd_Write_Char 530
SPI_Glcd_Write_Text 530
SPI_Glcd_Image 531
SPI_Glcd_PartialImage 531
Library Example 532
HW Connection 534
SPI Lcd Library 535
Library Dependency Tree 535
External dependencies of SPI Lcd Library 535
MikroElektronika
20
mikroPascal PRO for dsPIC30/33 and PIC24
Library Routines 535
SPI_Lcd_Cong 53 6
SPI_Lcd_Out 536
SPI_Lcd_Out_Cp 537
SPI_Lcd_Chr 537
SPI_Lcd_Chr_Cp 537
SPI_Lcd_Cmd 538
Available SPI Lcd Commands 538
Library Example 539
Default Pin Conguration 53 9
SPI Lcd8 (8-bit interface) Library 541
Library Dependency Tree 541
External dependencies of SPI Lcd Library 541
Library Routines 541
SPI_Lcd8_Cong 54 2
SPI_Lcd8_Out 542
SPI_Lcd8_Out_Cp 543
SPI_Lcd8_Chr 543
SPI_Lcd8_Chr_Cp 543
SPI_Lcd8_Cmd 544
Available SPI Lcd8 Commands 544
Library Example 545
SPI T6963C Graphic Lcd Library 547
Library Dependency Tree 547
External dependencies of SPI T6963C Graphic Lcd Library 547
Library Routines 548
SPI_T6963C_cong 54 9
SPI_T6963C_writeData 550
SPI_T6963C_writeCommand 550
SPI_T6963C_setPtr 551
SPI_T6963C_waitReady 551
SPI_T6963C_ll 55 1
SPI_T6963C_dot 552
SPI_T6963C_write_char 552
SPI_T6963C_write_text 553
SPI_T6963C_line 553
SPI_T6963C_rectangle 554
SPI_T6963C_rectangle_round_edges 554
SPI_T6963C_rectangle_round_edges_ll 55 5
SPI_T6963C_box 555
SPI_T6963C_circle 556
SPI_T6963C_circle_ll 55 6
SPI_T6963C_image 556
SPI_T6963C_PartialImage 557
SPI_T6963C_sprite 557
SPI_T6963C_set_cursor 558
21
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
SPI_T6963C_clearBit 558
SPI_T6963C_setBit 558
SPI_T6963C_negBit 559
SPI_T6963C_displayGrPanel 559
SPI_T6963C_displayTxtPanel 559
SPI_T6963C_setGrPanel 560
SPI_T6963C_setTxtPanel 560
SPI_T6963C_panelFill 560
SPI_T6963C_grFill 561
SPI_T6963C_txtFill 561
SPI_T6963C_cursor_height 561
SPI_T6963C_graphics 562
SPI_T6963C_text 562
SPI_T6963C_cursor 562
SPI_T6963C_cursor_blink 563
Library Example 563
HW Connection 567
T6963C Graphic Lcd Library 568
Library Dependency Tree 568
External dependencies of T6963C Graphic Lcd Library 569
Library Routines 570
T6963C_init 571
T6963C_writeData 572
T6963C_writeCommand 573
T6963C_setPtr 573
T6963C_waitReady 573
T6963C_ll 57 4
T6963C_dot 574
T6963C_write_char 575
T6963C_write_text 576
T6963C_line 576
T6963C_rectangle 577
T6963C_rectangle_round_edges 577
T6963C_rectangle_round_edges_ll 57 8
T6963C_box 578
T6963C_circle 578
T6963C_circle_ll 57 9
T6963C_image 579
T6963C_PartialImage 580
T6963C_sprite 580
T6963C_set_cursor 581
T6963C_displayGrPanel 581
T6963C_displayTxtPanel 581
T6963C_setGrPanel 582
T6963C_setTxtPanel 582
T6963C_panelFill 582
T6963C_grFill 583
MikroElektronika
22
mikroPascal PRO for dsPIC30/33 and PIC24
T6963C_txtFill 583
T6963C_cursor_height 583
T6963C_graphics 584
T6963C_text 584
T6963C_cursor 584
T6963C_cursor_blink 585
Library Example 585
HW Connection 589
TFT Library 590
External dependencies of TFT Library 590
Library Routines 591
TFT_Init 592
TFT_Set_Index 593
TFT_Write_Command 593
TFT_Write_Data 593
TFT_Set_Active 594
TFT_Set_Font 595
TFT_Write_Char 596
TFT_Write_Text 596
TFT_Fill_Screen 597
TFT_Dot 598
TFT_Set_Pen 599
TFT_Set_Brush 600
TFT_Line 602
TFT_H_Line 603
TFT_V_Line 603
TFT_Rectangle 603
TFT_Rectangle_Round_Edges 604
TFT_Circle 604
TFT_Image 604
TFT_Partial_Image 605
TFT_Image_Jpeg 605
TFT_RGBToColor16bit 606
TFT_Color16bitToRGB 606
HW Connection 607
Touch Panel Library 608
Library Dependency Tree 608
External dependencies of Touch Panel Library 608
Library Routines 608
TP_Init 609
TP_Set_ADC_Threshold 609
TP_Press_Detect 610
TP_Get_Coordinates 610
TP_Calibrate_Bottom_Left 611
TP_Calibrate_Upper_Right 611
TP_Get_Calibration_Consts 611
23
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
TP_Set_Calibration_Consts 612
Library Example 612
Touch Panel TFT Library 616
Library Dependency Tree 616
External dependencies of Touch Panel TFT Library 616
Library Routines 616
TP_TFT_Init 617
TP_TFT_Set_ADC_Threshold 617
TP_TFT_Press_Detect 618
TP_TFT_Get_Coordinates 619
TP_TFT_Calibrate_Min 619
TP_TFT_Calibrate_Max 619
TP_TFT_Get_Calibration_Consts 620
TP_TFT_Set_Calibration_Consts 620
HW Connection 621
UART Library 622
Library Routines 622
UARTx_Init 623
UARTx_Init_Advanced 624
UARTx_Data_Ready 625
UARTx_Tx_Idle 626
UARTx_Read 626
UARTx_Read_Text 627
UARTx_Write 628
UARTx_Write_Text 628
UART_Set_Active 629
Library Example 630
HW Connection 631
USB Library 632
USB HID Class 632
Library Routines 632
HID_Enable 633
HID_Read 633
HID_Write 633
HID_Disable 634
USB_Interrupt_Proc 634
USB_Polling_Proc 634
Gen_Enable 635
Gen_Read 635
Gen_Write 635
Library Example 636
HW Connection 636
Digital Signal Processing Libraries 637
Digital Signal Processing Libraries 637
FIR Filter Library 638
Library Routines 638
MikroElektronika
24
mikroPascal PRO for dsPIC30/33 and PIC24
FIR_Radix 638
IIR Filter Library 639
Library Routines 639
IIR_Radix 639
FFT Library 640
Library Dependency Tree 640
FFT 640
Twiddle Factors: 641
TwiddleCoeff_64 641
TwiddleCoeff_128 641
TwiddleCoeff_256 641
TwiddleCoeff_512 642
Bit Reverse Complex Library 644
Library Routines 644
BitReverseComplex 644
Vectors Library 645
Library Routines 645
Vector_Set 645
Vector_Power 646
Vector_Subtract 646
Vector_Scale 647
Vector_Negate 647
Vector_Multiply 648
Vector_Min 648
Vector_Max 649
Vector_Dot 649
Vector_Correlate 650
Vector_Convolve 651
Vector_Add 651
Matrix Library 652
Matrices Library 652
Library Routines 652
Matrix_Transpose 652
Matrix_Subtract 653
Matrix_Scale 653
Matrix_Multiply 654
Matrix_Add 655
Miscellaneous Libraries 656
Button Library 656
Library Routines 656
Button 657
C Type Library 658
Library Functions 658
isalnum 658
isalpha 658
25
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
iscntrl 658
isdigit 659
isgraph 659
islower 659
ispunct 659
isspace 659
isupper 660
isxdigit 660
toupper 660
tolower 660
Conversions Library 661
Library Dependency Tree 661
Library Routines 661
ByteToStr 662
ShortToStr 662
WordToStr 663
IntToStr 663
LongintToStr 664
LongWordToStr 664
FloatToStr 665
WordToStrWithZeros 666
IntToStrWithZeros 666
LongWordToStrWithZeros 667
LongIntToStrWithZeros 667
ByteToHex 668
ShortToHex 668
WordToHex 669
IntToHex 669
LongWordToHex 670
LongIntToHex 670
StrToInt 671
StrToWord 671
Bcd2Dec 671
Dec2Bcd 672
Bcd2Dec16 672
Dec2Bcd16 672
Setjmp Library 673
Library Routines 673
Setjmp 673
Longjmp 673
Library Example 674
String Library 675
Library Functions 675
memchr 675
memcmp 676
memcmp 676
MikroElektronika
26
mikroPascal PRO for dsPIC30/33 and PIC24
memcpy 676
memmove 677
memset 677
strcat 677
strcat2 678
strchr 678
strcmp 678
strcpy 679
strlen 679
strncat 679
strncpy 679
strspn 680
strncmp 680
strstr 680
strcspn 681
strpbrk 681
strrchr 681
ltrim 681
rtrim 682
strappendpre 682
strappendsuf 682
length 682
Time Library 683
Library Routines 683
Time_dateToEpoch 683
Time_epochToDate 684
Time_dateDiff 684
Library Example 685
TimeStruct type denition 68 6
Trigon Library 687
Library Routines 687
acos 687
asin 687
atan 688
atan2 688
ceil 688
cos 688
cosh 688
eval_poly 688
exp 689
fabs 689
oor 68 9
frexp 689
ldexp 689
log 689
log10 690
27
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
modf 690
pow 690
sin 690
sinh 690
sqrt 690
tan 691
tanh 691
Trigonometry Library 692
Library Routines 692
sinE3 692
cosE3 692
CHAPTER 10 693
Tutorials 693
Managing Project 693
Projects 693
New Project 694
New Project Wizard Steps 694
Customizing Projects 698
Managing Project Group 698
Add/Remove Files from Project 698
Project Level Denes: 69 9
Source Files 700
Managing Source Files 700
Creating new source le 700
Opening an existing le 700
Printing an open le 700
Saving le 700
Saving le under a different name 700
Closing le 701
Search Paths 701
Paths for Source Files (.mpas ) 702
Edit Project 702
Clean Project Folder 703
Compilation 704
Output Files 704
Assembly View 704
Creating New Library 705
Multiple Library Versions 705
Using Microchip MPLAB® IDE with mikroElektronika compilers 706
Debugging Your Code 706
Using MPLAB® ICD 2 Debugger 706
Using MPLAB® Simulator 713
Frequently Asked Questions 718
Can I use your compilers and programmer on Windows Vista (Windows 7) ? 718
MikroElektronika
28
mikroPascal PRO for dsPIC30/33 and PIC24
I am getting “Access is denied” error in Vista, how to solve this problem ? 718
What are differences between mikroC PRO, mikroPascal PRO and mikroBasic PRO compilers?718
Why do they have different prices ? 718
Why do your PIC compilers don’t support 12F508 and some similar chips ? 718
What are limitations of demo versions of mikroElektronika’s compilers ? 718
Why do I still get demo limit error when I purchased and installed license key ? 718
I have bought license for the older version, do I have to pay license for the new version of the compiler ? 719
Do your compilers work on Windows Vista (Windows 7) ? 719
What does this function/procedure/routine do ? 719
I try to compile one of the provided examples and nothing happens, what is the problem? 719
Can I get your library sources ? I need to provide all sources with my project. 719
Can I use code I developed in your compilers in commercial purposes ? Are there some limitations
? 719
Why does an example provided with your compilers doesn’t work ? 719
Your example works if I use the same MCU you did, but how to make it work for another MCU ? 719
I need this project nished, can you help me ? 72 0
Do you have some discount on your compilers/development systems for students/professors ? 720
I have a question about your compilers which is not listed here. Where can I nd an answer ? 72 0
29
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
CHAPTER 1
INTRODUCTION
mikroPascal PRO for dsPIC30/33 and PIC24 is a powerful, feature-rich development tool for the dsPIC30/33 and PIC24
microcontrollers. It is designed to provide the programmer with the easiest possible solution to developing applications
for embedded systems, without compromising performance or control.
mikroPascal PRO for dsPIC30/33 and PIC24 IDE
MikroElektronika
30