MikroElektronika mikroPascal PRO for dsPIC User guide

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 PIC24­based embedded applications. This development environment has a wide range of features such as: easy-to-use IDE, very compact and
efcient 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 - Predened classes 112 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 Specics 138
GOTO Table 139
Predened Globals and Constants 140
Predened project level denes 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 Specics 167
Types Efciency 168 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 Speciers 172
code 172 data 172 rx 172 sfr 172 xdata 173 ydata 173 dma 173
Memory Type Qualiers 174
Near Memory Qualier 174 Far Memory Qualier 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 Identiers 190
Case Sensitivity 190 Uniqueness and Scope 190 Identier Examples 190
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 Modier 198 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 Specier 217 Type Qualiers 217
Qualier const 217
Qualier 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_Modied 291 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 Specics: 339 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_Modied 401 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_Cong 430 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_Cong 536 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 Conguration 539
SPI Lcd8 (8-bit interface) Library 541
Library Dependency Tree 541 External dependencies of SPI Lcd Library 541 Library Routines 541 SPI_Lcd8_Cong 542 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_cong 549 SPI_T6963C_writeData 550 SPI_T6963C_writeCommand 550 SPI_T6963C_setPtr 551 SPI_T6963C_waitReady 551 SPI_T6963C_ll 551 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 555 SPI_T6963C_box 555 SPI_T6963C_circle 556 SPI_T6963C_circle_ll 556 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 574 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 578 T6963C_box 578 T6963C_circle 578 T6963C_circle_ll 579 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 denition 686
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 689 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 Denes: 699
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 com­piler ? 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 ? 720 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 ? 720
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
mikroPascal PRO for dsPIC30/33 and PIC24
Introduction to mikroPascal PRO for dsPIC30/33 and PIC24
dsPIC30/33 and PIC24 and mikroPascal PRO for dsPIC30/33 and PIC24 t together well: dsPIC is designed as a PIC with digital signal processing capabilities. These are Microchip’s rst inherent 16-bit (data) microcontrollers. They build
on the PIC’s existing strengths by offering hardware MAC (multiply-accumulate), barrel shifting, bit reversal, (16x16)-bit multiplication and other digital signal processing operations. Having a wide range of application and being also prized
for efciency, the dsPIC30/33 and PIC24 MCUs are a natural choice for developing embedded systems. mikroPascal
PRO for dsPIC30/33 and PIC24 provides a successful match featuring highly advanced IDE, broad set of hardware libraries, comprehensive documentation, and plenty of ready-to-run examples.
Features
mikroPascal PRO for dsPIC30/33 and PIC24 allows you to quickly develop and deploy complex applications:
- Write your source code using the built-in Code Editor (Code and Parameter Assistants, Code Folding, Syntax Highlighting, Auto Correct, Code Templates, and more.)
- Use included mikroPascal PRO for dsPIC30/33 and PIC24 libraries to dramatically speed up the development: data acquisition, memory, displays, conversions, communication etc.
- Monitor your program structure, variables, and functions in the Code Explorer.
- Generate commented, human-readable assembly, and standard HEX compatible with all programmers.
- Use the integrated mikroICD (In-Circuit Debugger) Real-Time debugging tool to monitor program execution on the hardware level.
- Inspect program ow and debug executable logic with the integrated Software Simulator. Generate COFF(Common Object File Format) le for software and hardware debugging under Microchip’s
MPLAB software.
- Use Single Static Assingment optimization to shrink your code to even smaller size.
- Get detailed reports and graphs: RAM and ROM map, code statistics, assembly listing, calling tree, and more.
- Active Comments enable you to make your comments alive and interactive.
- mikroPascal PRO for dsPIC30/33 and PIC24 provides plenty of examples to expand, develop, and use as
building bricks in your projects. Copy them entirely if you deem t – that’s why we included them with the
compiler.
Where to Start
- In case that you’re a beginner in programming the dsPIC30/33 and PIC24 microcontrollers, read carefully
the dsPIC Specics chapter. It might give you some useful information on the dsPIC30/33 and PIC24
constraints, code portability, and good programming practices.
- If you are experienced in Pascal programming, you will probably want to consult the mikroPascal PRO
for dsPIC30/33 and PIC24 Specics rst. For language issues, you can always refer to the comprehensive
Language Reference. A complete list of included libraries is available in the mikroPascal PRO for dsPIC30/33 and PIC24 Libraries.
- If you are not very experienced in Pascal programming, don’t panic! mikroPascal PRO for dsPIC30/33 and PIC24 provides plenty of examples making it easy for you to go quickly through it . We suggest you
to consult Projects and Source Files rst, and then start browsing the examples that you’re the most
interested in.
Copyright (c) 2002-2010 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
31
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
What’s new in mikroPascal PRO for dsPIC30/33 and PIC24
IDE build 4.60 Command line build 4.60
New features and enhancements in the following areas will boost your productivity by helping you complete many tasks more easily and in less time.
For a complete version history of mikroPascal PRO for dsPIC30/33 and PIC24, visit the following link: http://www.mikroe.com/download/eng/documents/compilers/mikropascal/pro/dspic/version_history.txt
- Compiler Changes
- IDE Changes
Compiler Changes
Fixed:
- Optimization issues in specic cases when destination variable is in Rx space.
IDE Changes
Fixed:
- Compiler version is not visible in caption if no projects are open.
- Parameter assistant ignores commas when switching to another parameter.
- Occasional lost of conguration ags when swithing between projets.
- Improper display of RAM memory usage in statistics.
Improved:
- Communication to programmer concerning supported chips.
- License Key Request form.
MikroElektronika
32
mikroPascal PRO for dsPIC30/33 and PIC24
Software License Agreement
mikroElektronika Associates License Statement and Limited Warranty
IMPORTANT - READ CAREFULLY
This license statement and limited warranty constitute a legal agreement (“License Agreement”) between you (either as an individual or a single entity) and mikroElektronika (“mikroElektronika Associates”) for software product (“Software”)
identied above, including any software, media, and accompanying on-line or printed documentation.
BY INSTALLING, COPYING, OR OTHERWISE USING SOFTWARE, YOU AGREE TO BE BOUND BY ALL TERMS AND CONDITIONS OF THE LICENSE AGREEMENT.
Upon your acceptance of the terms and conditions of the License Agreement, mikroElektronika Associates grants you the right to use Software in a way provided below.
This Software is owned by mikroElektronika Associates and is protected by copyright law and international copyright treaty. Therefore, you must treat this Software like any other copyright material (e.g., a book).
You may transfer Software and documentation on a permanent basis provided. You retain no copies and the recipient agrees to the terms of the License Agreement. Except as provided in the License Agreement, you may not transfer, rent, lease, lend, copy, modify, translate, sublicense, time-share or electronically transmit or receive Software, media
or documentation. You acknowledge that Software in the source code form remains a condential trade secret of
mikroElektronika Associates and therefore you agree not to modify Software or attempt to reverse engineer, decompile, or disassemble it, except and only to the extent that such activity is expressly permitted by applicable law notwithstanding this limitation.
If you have purchased an upgrade version of Software, it constitutes a single product with the mikroElektronika Associates software that you upgraded. You may use the upgrade version of Software only in accordance with the License Agreement.
LIMITED WARRANTY
Respectfully excepting the Redistributables, which are provided “as is”, without warranty of any kind, mikroElektronika Associates warrants that Software, once updated and properly used, will perform substantially in accordance with the accompanying documentation, and Software media will be free from defects in materials and workmanship, for a period of ninety (90) days from the date of receipt. Any implied warranties on Software are limited to ninety (90) days.
mikroElektronika Associates’ and its suppliers’ entire liability and your exclusive remedy shall be, at mikroElektronika Associates’ option, either (a) return of the price paid, or (b) repair or replacement of Software that does not meet mikroElektronika Associates’ Limited Warranty and which is returned to mikroElektronika Associates with a copy of your receipt. DO NOT RETURN ANY PRODUCT UNTIL YOU HAVE CALLED MIKROELEKTRONIKA ASSOCIATES FIRST AND OBTAINED A RETURN AUTHORIZATION NUMBER. This Limited Warranty is void if failure of Software has resulted from an accident, abuse, or misapplication. Any replacement of Software will be warranted for the rest of the original warranty period or thirty (30) days, whichever is longer.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MIKROELEKTRONIKA ASSOCIATES AND ITS SUPPLIERS DISCLAIM ALL OTHER WARRANTIES AND CONDITIONS, EITHER EXPRESSED OR IMPLIED, INCLUDED, BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO SOFTWARE, AND THE PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES.
33
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
IN NO EVENT SHALL MIKROELEKTRONIKA ASSOCIATES OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS AND BUSINESS INFORMATION, BUSINESS INTERRUPTION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE PRODUCT OR THE PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF MIKROELEKTRONIKA ASSOCIATES HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY CASE, MIKROELEKTRONIKA ASSOCIATES’ ENTIRE LIABILITY UNDER ANY PROVISION OF THIS LICENSE AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR SOFTWARE PRODUCT PROVIDED, HOWEVER, IF YOU HAVE ENTERED INTO A MIKROELEKTRONIKA ASSOCIATES SUPPORT SERVICES AGREEMENT, MIKROELEKTRONIKA ASSOCIATES’ ENTIRE LIABILITY REGARDING SUPPORT SERVICES SHALL BE GOVERNED BY THE TERMS OF THAT AGREEMENT.
HIGH RISK ACTIVITIES
Software is not fault-tolerant and is not designed, manufactured or intended for use or resale as on-line control equipment in hazardous environments requiring fail-safe performance, such as in the operation of nuclear facilities,
aircraft navigation or communication systems, air trafc control, direct life support machines, or weapons systems, in
which the failure of Software could lead directly to death, personal injury, or severe physical or environmental damage
(“High Risk Activities”). mikroElektronika Associates and its suppliers specically disclaim any expressed or implied warranty of tness for High Risk Activities.
GENERAL PROVISIONS
This statement may only be modied in writing signed by you and an authorised ofcer of mikroElektronika Associates.
If any provision of this statement is found void or unenforceable, the remainder will remain valid and enforceable according to its terms. If any remedy provided is determined to have failed for its essential purpose, all limitations of liability and exclusions of damages set forth in the Limited Warranty shall remain in effect.
This statement gives you specic legal rights; you may have others, which vary, from country to country. mikroElektronika Associates reserves all rights not specically granted in this statement.
mikroElektronika
Visegradska 1A, 11000 Belgrade, Europe.
Phone: + 381 11 36 28 830 Fax: +381 11 36 28 831 Web: www.mikroe.com E-mail: ofce@mikroe.com
MikroElektronika
34
mikroPascal PRO for dsPIC30/33 and PIC24
Technical Support
The latest software can be downloaded free of charge via Internet (you might want to bookmark the page so you could check news, patches, and upgrades later on): www.mikroe.com/en/compilers/mikroPascal PRO/dspic/download.htm .
In case you encounter any problem, you are welcome to our support forums at www.mikroe.com/forum/. Here, you may
also nd helpful information, hardware tips, and practical code snippets. Your comments and suggestions on future
development of the mikroPascal PRO for dsPIC30/33 and PIC24 are always appreciated — feel free to drop a note or two on our Wishlist.
In our Knowledge Base www.mikroe.com/en/kb/ you can nd the answers to Frequently Asked Questions and solutions to known problems. If you can not nd the solution to your problem in Knowledge Base then report it to Support Desk www.mikroe.com/en/support/. In this way, we can record and track down bugs more efciently, which is in our mutual
interest. We respond to every bug report and question in a suitable manner, ever improving our technical support.
How to Register
The latest version of the mikroPascal PRO for dsPIC30/33 and PIC24 is always available for downloading from our website. It is a fully functional software with the mikroICD(in-circuit Debugger), all the libraries, examples, and comprehensive help included.
The only limitation of the free version is that it cannot generate hex output over 2K of program words. Although it might sound restrictive, this margin allows you to develop practical, working applications with no thinking of demo limit. If you intend to develop really complex projects in the mikroPascal PRO for dsPIC30/33 and PIC24, then you should consider the possibility of purchasing the license key.
Who Gets the License Key
Buyers of the mikroPascal PRO for dsPIC30/33 and PIC24 are entitled to the license key. After you have completed the payment procedure, you have an option of registering your mikroPascal PRO for dsPIC30/33. In this way you can generate hex output without any limitations.
How to Get License Key
After you have completed the payment procedure, start the program. Select Help › How to Register from the drop-
down menu or click the How To Register Icon .
You can choose between two registering methods, I work online or I work ofine, based on your current internet connection and click Request license key now button:
35
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
If you choose I work online registering method, following page will be opened in your default browser:
MikroElektronika
36
mikroPascal PRO for dsPIC30/33 and PIC24
Fill out the registration form, select your distributor, and click the Submit button.
If you choose I work ofine registering method, following window will be opened:
Fill out the registration form, select your distributor, and click the Submit button.
This will start your e-mail client with message ready for sending. Review the information you have entered, and add the comment if you deem it necessary. Please, do not modify the subject line.
Upon receiving and verifying your request, we will send the license key to the e-mail address you specied in the
form.
After Receving the License Key
The license key comes as a small autoextracting le – just start it anywhere on your computer in order to activate
your copy of compiler and remove the demo limit. You do not need to restart your computer or install any additional components. Also, there is no need to run the mikroPascal PRO for dsPIC30/33 and PIC24 at the time of activation.
37
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Important:
- The license key is valid until you format your hard disk. In case you need to format the hard disk, you should request a new activation key.
- Please keep the activation program in a safe place. Every time you upgrade the compiler you should start this program again in order to reactivate the license.
MikroElektronika
38
mikroPascal PRO for dsPIC30/33 and PIC24
CHAPTER 2
mikroPascal PRO for dsPIC30/33 and PIC24 Environment
39
MikroElektronika
Main Menu Options
Available Main Menu options are:
mikoPascal PRO for dsPIC30/33 and PIC24
Related topics: Keyboard shortcuts, Toolbars
MikroElektronika
40
mikroPascal PRO for dsPIC30/33 and PIC24
File
File Menu Options
The File menu is the main entry point for manipulation with the source les.
File Description
Open a new editor window.
Open source le for editing or image le for viewing.
Reopen recently used le.
Save changes for active editor.
Save the active source le with the different name or change the le type.
Close active source le.
Close all opened les.
Print Preview.
Print.
Exit IDE.
Related topics: Keyboard shortcuts, File Toolbar, Managing Source Files
41
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Edit
Edit Menu Options
The Edit Menu contains commands for editing the contents of the current document.
Edit Description
Undo last change.
Redo last change.
Cut selected text to clipboard.
Copy selected text to clipboard.
Paste text from clipboard.
Delete selected text.
Select all text in active editor.
Find text in active editor.
Find next occurence of text in active editor.
Find previous occurence of text in active editor.
Replace text in active editor.
Find text in current le, in all opened les, or in les from desired folder.
Go to line to the desired line in active editor.
Advanced Code Editor options
MikroElektronika
42
mikroPascal PRO for dsPIC30/33 and PIC24
Advanced » Description
Comment selected code or put single line comment if there is no selection.
Uncomment selected code or remove single line comment if there is no selection.
Indent selected code.
Outdent selected code.
Changes selected text case to lowercase.
Changes selected text case to uppercase.
Changes selected text case to titlercase.
Find Text
Dialog box for searching the document for the specied text. The search is performed in the direction specied. If the
string is not found a message is displayed.
Replace Text
Dialog box for searching for a text string in le and replacing it with another text string.
43
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Find In Files
Dialog box for searching for a text string in current le, all opened les, or in les on a disk.
The string to search for is specied in the Text to nd eld. If Search in directories option is selected, The les to search are specied in the Files mask and Path elds.
Go To Line
Dialog box that allows the user to specify the line number at which the cursor should be positioned.
Regular expressions option
By checking this box, you will be able to advance your search, through Regular expressions.
Related topics: Keyboard shortcuts, Edit Toolbar, Advanced Edit Toolbar
MikroElektronika
44
mikroPascal PRO for dsPIC30/33 and PIC24
View
View Menu Options
View Menu contains commands for controlling the on-screen display of the current project.
45
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
View Description
Show/Hide Software Simulator / mikroICD (In-Circuit Debugger) debug windows.
Show/Hide Toolbars.
Show/Hide Bookmarks window.
Show/Hide Code Explorer window.
Show/Hide Library Manager window.
Show/Hide Macro Editor window.
Show/Hide Messages window.
Show/Hide Project Manager window.
Show/Hide Project Settings window.
Show/Hide Routine List in active editor.
Show/Hide Quick Converter window.
Show/Hide View Image Preview window.
View Assembly.
View Listing.
View Statistics.
Show Window List window.
The Tools toolbar can easily be customized by adding new tools in Options(F12) window.
Related topics: Keyboard shortcuts, Integrated Tools, Software Simulator
MikroElektronika
46
mikroPascal PRO for dsPIC30/33 and PIC24
Project
Project Menu Options
Project Menu allows the user to easily manipulate current project.
Project Description
Open New Project Wizard
Open existing project.
Open project group.
Open recently used project or project group.
Save current project.
Save active project le with the different name.
Close active project.
Close project group.
Add le to project.
Remove le from project.
Edit search paths.
Edit project settings
Clean Project Folder
Import projects created in previous versions of mikroPascal.
Export Project.
Related topics: Keyboard shortcuts, Project Toolbar, Creating New Project, Project Manager, Project Settings
47
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Build
Build Menu Options
Build Menu allows the user to easily manage building and compiling process.
Build Description
Build active project.
Rebuild all sources in acrive project.
Build all projects.
Stop building of all projects.
Build and program active project.
Related topics: Keyboard shortcuts, Project Toolbar, Creating New Project, Project Manager, Project Settings
MikroElektronika
48
mikroPascal PRO for dsPIC30/33 and PIC24
Run
Run Menu Options
Run Menu is used to debug and test compiled code on a software or harware level.
Run Description
Start Software Simulator or mikroICD (In-Circuit Debugger).
Stop debugger.
Run/Pause Debugger.
Step Into.
Step Over.
Step Out.
Run To Cursor.
Jump to interrupt in current project.
Toggle Breakpoint.
Clear Breakpoints.
Toggle between source and disassembly.
Related topics: Keyboard shortcuts, Debug Toolbar
49
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Tools
Tools Menu Options
Tools Menu contains a number of applications designed to ease the use of compiler and included library routines.
Tools Description
Run mikroElektronika Programmer
Run Package Manager
Show/Hide Active Comment Editor window.
Run ASCII Chart
Run EEPROM Editor
Generate HTML code suitable for publishing source code on the web.
Run Filter Designer Tool
Run Glcd bitmap editor
Run HID Terminal
Run Lcd custom character
Run Seven Segment Editor
Run UDP communication terminal
Run USART Terminal
Open Options window
Related topics: Keyboard shortcuts, Tools Toolbar
MikroElektronika
50
mikroPascal PRO for dsPIC30/33 and PIC24
Help
Help Menu Options
Help Description
Оpen Help File.
Оpen Code Migration Document.
Check if new compiler version is available.
Open mikroElektronika Support Forums in a default browser.
Open mikroElektronika Web Page in a default browser.
Information on how to register
Open About window.
Related topics: Keyboard shortcuts, Help Toolbar
51
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
mikroPascal PRO for dsPIC30/33 and PIC24 IDE
IDE Overview
The mikroPascal PRO for dsPIC30/33 and PIC24 is an user-friendly and intuitive environment.
For a detailed information on a certain part of IDE, simply click on it (hovering a mouse cursor above a desired IDE part will pop-up its name):
- The Code Editor features adjustable Syntax Highlighting, Code Folding, Code Assistant, Parameters Assistant, Spell Checker, Auto Correct for common typos and Code Templates (Auto Complete).
- The Code Explorer is at your disposal for easier project management.
- The Project Manager alows multiple project management
- General project settings can be made in the Project Settings window
- Library manager enables simple handling libraries being used in a project
- The Messages Window displays all information, messages and errors detected during compiling and linking.
- The source-level Software Simulator lets you debug executable logic step-by-step by watching the program ow.
- The New Project Wizard is a fast, reliable, and easy way to create a project.
- Help les are syntax and context sensitive.
- Like in any modern Windows application, you may customize the layout of mikroPascal PRO for dsPIC30/33 and PIC24 to suit your needs best.
- Spell checker underlines identiers which are unknown to the project. In this way it helps the programmer to spot
potential problems early, much before the project is compiled.
- Spell checker can be disabled by choosing the option in the Preferences dialog (F12).
MikroElektronika
52
mikroPascal PRO for dsPIC30/33 and PIC24
Code Editor
The Code Editor is advanced text editor fashioned to satisfy needs of professionals. General code editing is the same as working with any standard text-editor, including familiar Copy, Paste and Undo actions, common for Windows environment.
Available Code Editor options are: Editor Settings, Editor Colors, Auto Correct, Auto Complete and Style.
Editor Settings
Main Editor Settings Features are:
- Auto Save
- Highlighter
- Spelling
- Comment Style
- Code Folding
- Code Assistant
- Parameter Assistant
- Bookmarks and Go to Line
53
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Auto Save
Auto Save is a function which saves an opened project automatically, helping to reduce the risk of data loss in case of
a crash or freeze. Autosaving is done in time intervals dened by the user.
Highlighter
Highlighting is a convenient feature for spotting brackets which notate begin or end of a routine, by making them visually distinct.
Spelling
The Spell Checker underlines unknown objects in the code, so they can be easily noticed and corrected before compiling your project.
Select Tools › Options from the drop-down menu, or click the Show Options Icon and then select the Spell Checker Tab.
Comment Style
Code Editor has a feature to change the comment style to either single-line or multi-line. Commenting or uncommenting
the selected code is done by a simple click of a mouse, using the Comment Icon and Uncomment Icon from
the Advanced Edit Toolbar.
Code Folding
Code folding is IDE feature which allows users to selectively hide and display sections of a source le. In this way it is
easier to manage large regions of code within one window, while still viewing only those subsections of the code that are relevant during a particular editing session.
While typing, the code folding symbols ( and ) appear automatically. Use the folding symbols to hide/unhide the code subsections.
MikroElektronika
54
mikroPascal PRO for dsPIC30/33 and PIC24
Another way of folding/unfolding code subsections is by using Alt+← and Alt+→.
If you place a mouse cursor over the tooltip box, the collapsed text will be shown in a tooltip style box.
Code Assistant
If you type the rst few letters of a word and then press Ctrl+Space, all valid identiers matching the letters you have typed will be prompted in a oating panel (see the image below). Now you can keep typing to narrow the choice, or you
can select one from the list using the keyboard arrows and Enter.
Parameter Assistant
The Parameter Assistant will be automatically invoked when you open parenthesis “(” or press Shift+Ctrl+Space. If the
name of a valid function precedes the parenthesis, then the expected parameters will be displayed in a oating panel.
As you type the actual parameter, the next expected parameter will become bold.
Bookmarks
Bookmarks make navigation through a large code easier. To set a bookmark, use Ctrl+Shift+number. The same princliple applies to the removal of the bookmarks. To jump to a bookmark, use Ctrl+number.
Go to Line
The Go to Line option makes navigation through a large code easier. Use the shortcut Ctrl+G to activate this option.
55
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Column Select Mode
This mode changes the operation of the editor for selecting text. When column select mode is used, highlighted text
is based on the character column position of the rst character selected to the column of the last character of text
selected. Text selected in this mode does not automatically include all text between the start and end position, but includes all
text in the columns between the rst and last character selected.
Column mode editing is sometimes referred to as block mode editing as the act of selecting text forms a rectangle.
To enter this mode, press Alt + Left mouse button, drag the mouse towards the desired direction thus selecting the text.
Editor Colors
MikroElektronika
56
mikroPascal PRO for dsPIC30/33 and PIC24
Editor Colors option allows user to set, change and save text and color settings organized in schemes. Schemes represent custom graphical appearance that can be applied to GUI (Graphical User Interface) to satisfy tastes of different users.
Auto Correct
Auto Correct option facilitates the user in such a fashion that it automatically corrects common typing or spelling errors as it types.
This option is already set up to automatically correct some words. For example, if you type whiel, it will be corrected to while when you press the spacebar:
57
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
The user can easily add its common typos by entering original typo, for example btye, to the Original box, and replacement, byte, to the Replacement box, and just click "Add" button. Next time when the typo occurs, it will be automatically corrected.
Auto Complete (Code Templates)
Auto Complete option saves lots of keystrokes for commonly used phrases by automatically completing user's typing.
MikroElektronika
58
mikroPascal PRO for dsPIC30/33 and PIC24
The user can insert the Code Template by typing the name of the template (for instance, dow), then press Ctrl+J and the Code Editor will automatically generate a code:
You can add your own templates to the list by entering the desired keyword, description and code of your template in appropriate boxes. Autocomplete macros can retreive system and project information:
- %DATE% - current system date
- %TIME% - current system time
- %DEVICE% - device (MCU) name as specied in project settings
- %DEVICE_CLOCK% - clock as specied in project settings
- %COMPILER% - current compiler version
These macros can be used in template code, see template ptemplate provided with mikroPascal PRO for dsPIC30/33 and PIC24 installation.
59
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Code Explorer
The Code Explorer gives clear view of each item declared inside the source code. You can jump to a declaration of
any item by double clicking it, or pressing the Enter button. Also, besides the list of dened and declared objects, code explorer displays message about the rst error and it's location in code.
The following options are available in the Code Explorer:
Icon Description
Expand/Collapse all nodes in tree.
Locate declaration in code.
MikroElektronika
60
mikroPascal PRO for dsPIC30/33 and PIC24
Routine List
Routine list diplays list of routines, and enables ltering routines by name. Routine list window can be accessed by
pressing Ctrl+L.
You can jump to a desired routine by double clicking on it, or pressing the Enter button. Also, you can sort routines by size or by address.
Project Manager
Project Manager is IDE feature which allows the users to manage multiple projects. Several projects which together make project group may be open at the same time. Only one of them may be active at the moment. Setting project in active mode is performed by double clicking the desired project in the Project Manager, which will result in bolding the project's name. Also, the name of the currently active project will be diplayed in the Program Manager window title, alongside with the number of projects in project group.
61
MikroElektronika
The following options are available in the Project Manager:
Icon Description
mikoPascal PRO for dsPIC30/33 and PIC24
For details about adding and removing les from project see Add/Remove Files from Project.
Save project Group.
Open project group.
Close the active project.
Close project group.
Add project to the project group.
Remove project from the project group.
Add le to the active project.
Remove selected le from the project.
Build the active project.
Run mikroElektronika’s Flash programmer.
Related topics: Project Settings, Project Menu Options, File Menu Options, Project Toolbar, Build Toolbar, Add/Remove Files from Project
MikroElektronika
62
mikroPascal PRO for dsPIC30/33 and PIC24
Project Settings
The following options are available in the Project Settings window:
- Device - select the appropriate device from the device drop-down list.
- MCU Clock - enter the clock frequency value.
- Build/Debugger Type - choose debugger type.
Related topics: Edit Project, Customizing Projects, Project Manager
63
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Library Manager
Library Manager enables simple handling libraries being used in a project. Library Manager window lists all libraries (extension .mcl) which are instantly stored in the compiler Uses folder. The desirable library is added to the project by selecting check box next to the library name.
In order to have all library functions accessible, simply press the button Check All and all libraries will be selected.
In case none library is needed in a project, press the button Clear All and all libraries will be cleared from the
project.
Only the selected libraries will be linked.
Icon Description
Refresh Library by scanning les in “Uses” folder.Useful when new libraries are added by copying les to
“Uses” folder.
Rebuild all available libraries. Useful when library sources are available and need refreshing.
Include all available libraries in current project.
No libraries from the list will be included in current project.
Restore library to the state just before last project saving.
MikroElektronika
64
mikroPascal PRO for dsPIC30/33 and PIC24
Managing libraries using Package Manager
The Package Manager is a tool which enables users to easily install their own libraries in the mikroIDE. Libraries are
distributed in the form of a package, which is an archive composed of one or more les, containing libraries. For more
information on Package Manager, visit our website.
Upon package installation, a new node with the package name will be created in the Library Manager. For example:
From the Library Manager, the user can also uninstall the desired package by right clicking the the appropriate node, and from the drop-down menu choose Uninstall package:
Related topics: mikroPascal PRO for PIC Libraries, Creating New Library
65
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Routine List
Routine list diplays list of routines, and enables ltering routines by name. Routine list window can be accessed by
pressing Ctrl+L.
You can jump to a desired routine by double clicking on it, or pressing the Enter button. Also, you can sort routines by size or by address.
Statistics
After successful compilation, you can review statistics of your code. Click the Statistics Icon .
Memory Usage Windows
Provides overview of RAM and ROM usage in the various forms.
MikroElektronika
66
mikroPascal PRO for dsPIC30/33 and PIC24
RAM Memory Usage
Displays RAM memory usage in a pie-like form.
Used RAM Locations
Displays used RAM memory locations and their names.
67
MikroElektronika
SFR Locations
Displays list of used SFR locations.
mikoPascal PRO for dsPIC30/33 and PIC24
ROM Memory Usage
Displays ROM memory space usage in a pie-like form.
MikroElektronika
68
mikroPascal PRO for dsPIC30/33 and PIC24
ROM Memory Constants
Displays ROM memory constants and their addresses.
Functions
Sorts and displays functions in various ways.
69
MikroElektronika
Functions Sorted By Name Chart
Sorts and displays functions by their name, in the ascending order.
mikoPascal PRO for dsPIC30/33 and PIC24
Functions Sorted By Size Chart
Sorts and displays functions by their sizes in a chart-like form.
MikroElektronika
70
mikroPascal PRO for dsPIC30/33 and PIC24
Functions Sorted By Addresses
Sorts and displays functions by their addresses, in the ascending order.
Function Tree
Displays Function Tree with the relevant data for each function.
71
MikroElektronika
Memory Summary
Displays summary of RAM and ROM memory in a pie-like form.
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
72
mikroPascal PRO for dsPIC30/33 and PIC24
Messages Window
Messages Window displays various informations and notications about the compilation process.
It reports for example, time needed for preprocessing, compilation and linking; used RAM and ROM space, generated
baud rate with error percentage, etc.
The user can lter which notications will Messages Window display by checking Errors, Warning and Hints box.
In case that errors were encountered during compiling, the compiler will report them and won’t generate a hex le. The
Messages Window will display errros at the bottom of the window by default.
The compiler also reports warnings, but these do not affect the output; only errors can interefere with the generation
of hex.
Double click the message line in the Message Window to highlight the line where the error was encountered.
73
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Quick Converter
Quick Converter enables the user to easily transform numbers from one base to another.
The user can convert integers of various sizes (8, 16 or 32 bits), signed and unsigned, using different representation (decimal, hexadecimal, binary and character).
Also, Quick Converter features oat point numbers conversion from/to Float Decimal, Float 32bit (IEEE), Float 32bit
(Microchip) and Radix 1.15 for dsPIC family of MCUs.
Macro Editor
A macro is a series of keystrokes that have been 'recorded' in the order performed. A macro allows you to 'record' a series of keystrokes and then 'playback', or repeat, the recorded keystrokes.
MikroElektronika
74
mikroPascal PRO for dsPIC30/33 and PIC24
The Macro offers the following commands:
Icon Description
Related topics: Code Editor, Code Templates
Starts ‘recording’ keystrokes for later playback.
Stops capturing keystrokes that was started when the Start Recording command was selected.
Allows a macro that has been recorded to be replayed.
New macro.
Delete macro.
Image Preview
There are a lot of occassions in which the user besides the code, must look at the appropriate schematics in order to succesfully write the desired program. The mikroPascal PRO for dsPIC30/33 and PIC24 provides this possibility through the Image Preview Window.
To add an image to the Image Preview Window, right click the Image Files node in the Project Manager:
75
MikroElektronika
Now, navigate to the desired image le, and simply add it:
Next, right click the added le, and choose Set As Preview Image:
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
76
mikroPascal PRO for dsPIC30/33 and PIC24
Once you have added the image, it will appear in the Image Preview Window:
Also, you can add multiple images to the Image Files node, but only the one that is set will be automatically displayed in the Image Preview Window upon opening the project.
By changing the Image Preview Window size, displayed image will be t by its height in such a way that its proportions will remain intact.
Toolbars
This section provides an overview of the toolbars available in mikroPascal PRO for dsPIC30/33 and PIC24 Help:
- File Toolbar
- Edit Toolbar
- Advanced Edit Toolbar
- Find Toolbar
- Project Toolbar
- Build Toolbar
- Debug Toolbar
- Styles Toolbar
- Tools Toolbar
- View Toolbar
- Layout Toolbar
- Help Toolbar
77
MikroElektronika
File Toolbar
File Toolbar is a standard toolbar with the following options:
Icon Description
mikoPascal PRO for dsPIC30/33 and PIC24
Opens a new editor window.
Open source le for editing or image le for viewing.
Save changes for active window.
Save changes in all opened windows.
Print Preview.
Print.
Edit Toolbar
Edit Toolbar is a standard toolbar with the following options:
Icon Description
Undo last change.
Redo last change.
Cut selected text to clipboard.
Copy selected text to clipboard.
Paste text from clipboard.
MikroElektronika
78
mikroPascal PRO for dsPIC30/33 and PIC24
Advanced Edit Toolbar
Advanced Edit Toolbar comes with the following options:
Icon Description
Comment selected code or put a single line comment if there is no selection
Uncomment selected code or remove single line comment if there is no selection.
Select text from starting delimiter to ending delimiter.
Go to ending delimiter.
Go to line.
Indent selected code lines.
Outdent selected code lines.
Generate HTML code suitable for publishing current source code on the web.
Find/Replace Toolbar
Find/Replace Toolbar is a standard toolbar with the following options:
Icon Description
Find text in current editor.
Find next occurence.
Find previous occurence.
Replace text.
Find text in les.
79
MikroElektronika
Project Toolbar
Project Toolbar comes with the following options:
Icon Description
mikoPascal PRO for dsPIC30/33 and PIC24
New project.
Open Project
Save Project
Edit project settings.
Close current project.
Clean project folder.
Add File To Project
Remove File From Project
Build Toolbar
Build Toolbar comes with the following options:
Icon Description
Build current project.
Build all opened projects.
Build and program active project.
Start programmer and load current HEX le.
MikroElektronika
80
mikroPascal PRO for dsPIC30/33 and PIC24
Debug Toolbar
Debug Toolbar comes with the following options:
Icon Description
Start Software Simulator or mikroICD (In-Circuit Debugger).
Run/Pause Debugger.
Stop Debugger.
Step Into.
Step Over.
Step Out.
Run To Cursor.
Toggle Breakpoint.
View Breakpoints Window
Clear Breakpoints.
View Watch Window
View Stopwatch Window
Styles Toolbar
Styles toolbar allows you to easily change colors of your workspace.
81
MikroElektronika
Tools Toolbar
Tools Toolbar comes with the following default options:
Icon Description
mikoPascal PRO for dsPIC30/33 and PIC24
Tip : The Tools toolbar can easily be customized by adding new tools in Options menu window.
Run USART Terminal
EEPROM
ASCII Chart
Seven Segment Editor.
Open Active Comment editor.
Options menu
View Toolbar
View Toolbar provides access to assembly code, listing le and statistics windows.
Icon Description
Open assembly code in editor.
Open listing le in editor.
View statistics for current project.
MikroElektronika
82
mikroPascal PRO for dsPIC30/33 and PIC24
Layout Toolbar
Styles toolbar allows you to easily customize workspace through a number of different IDE layouts.
Icon Description
Delete the selected layout.
Save the current layout.
Set the selected layout.
Help Toolbar
Help Toolbar provides access to information on using and registering compilers:
Icon Description
Related topics: Keyboard shortcuts, Integrated Tools, Debug Windows
Open Help le.
How To Register.
83
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Customizing IDE Layout
Docking Windows
You can increase the viewing and editing space for code, depending on how you arrange the windows in the IDE.
Step 1: Click the window you want to dock, to give it focus.
Step 2: Drag the tool window from its current location. A guide diamond appears. The four arrows of the diamond point
towards the four edges of the IDE.
MikroElektronika
84
mikroPascal PRO for dsPIC30/33 and PIC24
Step 3: Move the pointer over the corresponding portion of the guide diamond. An outline of the window appears in the designated area.
Step 4: To dock the window in the position indicated, release the mouse button.
Tip : To move a dockable window without snapping it into place, press CTRL while dragging it.
Saving Layout
Once you have a window layout that you like, you can save the layout by typing the name for the layout and pressing
the Save Layout Icon .
To set the layout select the desired layout from the layout drop-down list and click the Set Layout Icon .
To remove the layout from the drop-down list, select the desired layout from the list and click the Delete Layout
Icon .
Auto Hide
Auto Hide enables you to see more of your code at one time by minimizing tool windows along the edges of the IDE when not in use.
- Click the window you want to keep visible to give it focus.
- Click the Pushpin Icon on the title bar of the window.
85
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
When an auto-hidden window loses focus, it automatically slides back to its tab on the edge of the IDE. While a window is auto-hidden, its name and icon are visible on a tab at the edge of the IDE. To display an auto-hidden window, move your pointer over the tab. The window slides back into view and is ready for use.
Options
Options menu consists of three tabs: Code Editor, Tools and Output settings.
Code editor
The Code Editor is advanced text editor fashioned to satisfy needs of professionals.
Tools
The mikroPascal PRO for dsPIC30/33 and PIC24 includes the Tools tab, which enables the use of shortcuts to external programs, like Calculator or Notepad. You can set up to 10 different shortcuts, by editing Tool0 - Tool9.
MikroElektronika
86
mikroPascal PRO for dsPIC30/33 and PIC24
Output settings
By modifying Output Settings, user can congure the content of the output les. You can enable or disable, for example, generation of ASM and List le.
Also, user can choose optimization level, and compiler specic settings, which include case sensitivity, dynamic link for string literals setting (described in mikroPascal PRO for dsPIC30/33 and PIC24 specics).
Build all les as library enables user to use compiled library (*.mcl) on any MCU (when this box is checked), or for a
selected MCU (when this box is left unchecked).
For more information on creating new libraries, see Creating New Library.
87
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
88
mikroPascal PRO for dsPIC30/33 and PIC24
Integrated Tools
Active Comments Editor
Active Comments Editor is a tool, particularly useful when working with Lcd display. You can launch it from the drop-
down menu Tools › Active Comments Editor or by clicking the Active Comment Editor Icon from Tools toolbar.
89
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
ASCII Chart
The ASCII Chart is a handy tool, particularly useful when working with Lcd display. You can launch it from the drop-
down menu Tools › ASCII chart or by clicking the View ASCII Chart Icon from Tools toolbar.
MikroElektronika
90
mikroPascal PRO for dsPIC30/33 and PIC24
EEPROM Editor
The EEPROM Editor is used for manipulating MCU's EEPROM memory. You can launch it from the drop-down menu Tools › EEPROM Editor.
When you run mikroElektronika programmer software from mikroPascal PRO for dsPIC30/33 and PIC24 IDE -
project_name.hex le will be loaded automatically while ihex le must be loaded manually.
Filter Designer
The Filter designer is a tool for designing FIR and IIR lters. It has an user-friendly visual interface for setting the lter
parameters. Filter designer output is the mikroPascal PRO for dsPIC30/33 and PIC24 compatible code. You can launch it from the drop-down menu Tools › Filter Designer.
91
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Graphic Lcd Bitmap Editor
The mikroPascal PRO for dsPIC30/33 and PIC24 includes the Graphic Lcd Bitmap Editor. Output is the mikroPascal PRO for dsPIC30/33 and PIC24 compatible code. You can launch it from the drop-down menu Tools › Glcd Bitmap Editor.
MikroElektronika
92
mikroPascal PRO for dsPIC30/33 and PIC24
HID Terminal
The mikroPascal PRO for dsPIC30/33 and PIC24 includes the HID communication terminal for USB communication. You can launch it from the drop-down menu Tools › HID Terminal.
93
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
Lcd Custom Character
mikroPascal PRO for dsPIC30/33 and PIC24 includes the Lcd Custom Character. Output is mikroPascal PRO for dsPIC30/33 and PIC24 compatible code. You can launch it from the drop-down menu Tools › Lcd Custom Character.
MikroElektronika
94
mikroPascal PRO for dsPIC30/33 and PIC24
Seven Segment Editor
The Seven Segment Editor is a convenient visual panel which returns decimal/hex value for any viable combination you would like to display on seven segment display. Click on the parts of seven segment image to get the requested value
in the edit boxes. You can launch it from the drop-down menu Tools › Seven Segment Editor or by clicking the Seven
Segment Editor Icon from Tools toolbar.
UDP Terminal
The mikroPascal PRO for dsPIC30/33 and PIC24 includes the UDP Terminal. You can launch it from the drop-down menu Tools › UDP Terminal.
95
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
USART Terminal
The mikroPascal PRO for dsPIC30/33 and PIC24 includes the USART communication terminal for RS232 communication.
You can launch it from the drop-down menu Tools › USART Terminal or by clicking the USART Terminal Icon from
Tools toolbar.
MikroElektronika
96
mikroPascal PRO for dsPIC30/33 and PIC24
Active Comments
The idea of Active Comments is to make comments alive and give old fashioned comments new meaning and look. From now on, you can assign mouse event on your comments and 'tell' your comments what to do on each one. For example, on left mouse click, open some web address in your browser, on mouse over show some picture and on
mouse double click open some le.
Suppose we are writing a example for a GSM/GPSR module which is connected to the EasyPIC6 and we would like to provide a photo of our hardware (jumpers, cables, etc.). within the example. It would also be nice to put some documentation about chip we are using and a GSM module extra board. Now we can have all those things dened in one single comment using Active Comment Editor.
New Active Comment
When you start Active Comment Editor for the rst time (from the View menu, from editor's pop-up menu, or by pressing
Ctrl + Alt + P) you will get an empty editor:
By clicking the button you are prompted to enter a name for the comment:
97
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
You can notice that when you start typing a name, properties pane is automatically displayed so you can edit properties
if you wish. A Comment will be is created when you click button.
Properties are consisted of two major categories - Attributes and Events.
Attributes can be:
- URL - Valid web address.
- Image - Image has to be previously added to Project (Project Manager > Images).
- File - File has to be previously added to Project (Project Manager > Other Files).
There are four predened event types you can apply to an Active Comment:
1. OnLeftClick + Alt
2. OnRightClick
3. OnDoubleClick
4. OnMouseOver
MikroElektronika
98
mikroPascal PRO for dsPIC30/33 and PIC24
First three event types can have one of the following three actions:
1. OpenUrl - Opens entered URL in default Web browser.
2. OpenFile - Opens a le within a default program associated with the le extension (dened by Windows).
3. None - Does nothing.
The fourth event, OnMouseOver, has only 2 actions:
1. PreviewImage - Shows image when cursor is moved over a comment.
2. None - Does nothing.
Attributes are tightly bounded with events. For example, you can not have OnLeftClick + Alt -> OpenFile if there is no
le attribute set, or if there is no le added to project. The same behavior applies to image attribute.
Let's start editing our Active Comment by entering some valid web address in the URL eld:
For every Active Comment a XML le will be created, containing all valid information regarding the Active Comment -
attributes, events, etc. and it is automatically added to Project manager after saving it:
99
MikroElektronika
mikoPascal PRO for dsPIC30/33 and PIC24
You can see the contents of the created XML le by expanding Active Comment Editor:
As we mentioned above you can add image or le which are already included in project. If the the desired image or le
aren't added, you can do it directly from here by clicking the or button.
MikroElektronika
100
Loading...