Microchip Technology DM164130-9 User Manual

Page of 101
PICkit™ 3 Starter Kit User’s Guide
DS41628B-page 96
 2012 Microchip Technology Inc.
A.1
USEFUL MPLAB
® 
X SHORTCUTS
MPLAB X provides several new features to the MPLAB IDE. It is based on the existing 
development platform, Netbeans. The following is a list of useful shortcuts available 
while developing code:
1. ALT+SHIFT+’F’ 
a) Auto Format code
2. CTRL+E
a) Delete the currently selected line and move up the next 
3. CTRL+SEMICOLON
a) Append a semicolon to the end of the currently selected line
4. CTR+SHIFT+UP
a) Copy the selected line to a new line below it
b) Supports multiple lines via highlighting
• Custom macros can be created by going to edit->start macro recording
• Hover over any function call and hold CTRL to go to that function definition. 
Visit 
netbeans.com
 to learn more shortcuts. The forums will provide a great deal of help 
as well. 
A.2
FINDING REGISTER NAMES
All of the register definitions are defined in a header file that must be included at the top 
of each source file. For these lessons, the expected system directory locations are as 
follows:
Assembler (MPASM):
1. C:\Program Files\Microchip\MPASM Suite\P18F14K22.inc
2. C:\Program Files\Microchip\MPASM Suite\P16F1829.inc
XC8
1. C:\Program Files\microchip\xc8\v1.00\include\pic16f1829.h
2. C:\Program Files\microchip\xc8\v1.00\include\pic18f14K22.h
A.3
PIC MCU ASSEMBLY CODING PRACTICES:
In general, assembly should be commented profusely due to the complexity and obscu-
rity of the language. 
• Write to the latch, read from the port.
• Use bit operations (bcf/bsf) when modifying important parts that should be 
emphasized instead of a simple movlw.
• Put the Interrupt Service Routine (ISR) as the last function. 
• Assembler directives should be in lowercase: 
res, org, #define, #include, banksel, …
• Labels should be descriptive and should have a colon. 
• Do not hard code addresses. Use clbock/endc (non-linker) or #pragma 
udata sections (linker) to allow assembler or linker to assign variable 
addresses.