MPLAB C18 C MPLAB C18
MPLAB C18 C
MPLAB C18 C #define START, c:\mcc18 errorlevel{0 1} char isascii(char ch); list[list_optioin,list_option] OK, Cancel <Tab>,<Ctrl-C> MPLAB IDE User s Guide
MPLAB C18 C
MPLAB C18 C 1MPLAB C18 1.1 1.2 1.3 MPLAB C18
MPLAB C18 C 1.4 1.5
MPLAB C18 C
MPLAB C18 C 2MPLAB C18 2.1 MPLAB C18 2.2 MPLAB C18 Next Next
MPLAB C18 C Browse C:\mcc18
MPLAB C18 C Next
MPLAB C18 C Next
MPLAB C18 C Add MPLAB C18 to PATH environment variable Add MPASM to PATH environment variable Add header file path to MCC_INCLUDE environment variable
MPLAB C18 C Modify PATH and MCC_INCLUDE variable for all users Update MPLAB IDE v5.xx to use this MPLAB C18 Update MPLAB IDE v5.xx to use this MPLINK linker Make local default storage class static in MPLAB IDE v5.xx Update MPLAB IDE v6.xx to use this MPLAB C18
MPLAB C18 C Update MPLAB IDE v6.xx to use this MPLINK linker Next
MPLAB C18 C 3 3.1 3.2 1 c:\mcc18\example\getting_started\example1 /* * This is example 1 from "Getting Started with MPLAB C18". */ #include <p18cxxx.h> /* for TRISB and PORTB declarations */ int counter; void main (void) { counter = 1;
MPLAB C18 C } TRISB = 0; /* configure PORTB for output */ while (counter <= 15) { PORTB = counter; /* display value of 'counter' on the LEDs */ counter++; } Project>New c:\mcc18\example\getting_started\example1 OK
MPLAB C18 C Configure > Select Device OK
MPLAB C18 C Project > Select Language Toolsuite Set Language Toolsuite Microchip C18 Toolsuite OK Set Language Toolsuite Select Language Toolsuite Toolsuite Contents
MPLAB C18 C Toolsuite Contents Project > Build Options > Project Project > Build Options > Project General
MPLAB C18 C Include Path,$(INCDIR) c:\mcc18\h Include Path Library Path,$(LIBDIR) Linker-Script Path,$(LKRDIR) c:\mcc18\lib c:\mcc18\lkr Intermediate Directory General Build Option
MPLAB C18 C Build Option MPLINK Linker MPLINK Linker Generate map file OK
MPLAB C18 C Add files
MPLAB C18 C c:\mcc18\example\getting_started\example1 Header Files #include<xxx.h> Include Directory #include xxx.h c:\mcc18\lkr
MPLAB C18 C Project>Build 3.2.7 MPLAB SIM Debugger>select Tool>MPLAB SIM
MPLAB C18 C Set Breakpoint
MPLAB C18 C Watch Watch View>Watch Watch Counter Add Symbol
MPLAB C18 C Run
MPLAB C18 C Watch File> Open Symbols - Sorted by Name Name Address Location Storage File --------- --------- --------- --------- --------- counter 0x00008a data extern :c\mcc18\example\getting_started\example1\example1.c
MPLAB C18 C C., (disassembly code).. Address Value Disassembly Source -------- -------- ------------------ ------------------------------ #include <p18cxxx.h> /* for TRISB and PORTB declarations */ int counter; void main (void) { 0000e2 0e01 MOVLW 0x1 counter = 1; 0000e4 0100 MOVLB 0x0 0000e6 6f8a MOVWF 0x8a,0x1 0000e8 6b8b CLRF 0x8b,0x1 0000ea 6a93 CLRF 0x93,0x0 TRISB = 0; /* configure PORTB for output */ C:\mcc18\example\getting_started\example1\example1.c 0000ec 518b MOVF 0x8b,0x0,0x1 while (counter <= 15) 0000ee 0a00 XORLW 0x0 0000f0 aee8 BTFSS 0xe8,0x7,0x0 0000f2 d002 BRA 0xf8 0000f4 358b RLCF 0x8b,0x0,0x1 0000f6 d005 BRA 0x102 0000f8 0e0f MOVLW 0xf 0000fa 80d8 BSF 0xd8,0x0,0x0 0000fc 558a SUBFWB 0x8a,0x0,0x1 0000fe 0e00 MOVLW 0x0 000100 558b SUBFWB 0x8b,0x0,0x1 000102 e306 BNC 0x110 00010e d7ee BRA 0xec { 000104 c08a MOVFF 0x8a,0xf81 PORTB = counter; /* display value of 'counter' on the LEDs */ 000106 ff81 000108 2b8a INCF 0x8a,0x1,0x1 counter++; 00010a 0e00 MOVLW 0x0 00010c 238b ADDWFC 0x8b,0x1,0x1 } 000110 0012 RETURN 0x0 }
MPLAB C18 C 3.2.9 MPLAB ICD2 Linker Scripts Project>BuildAll Debugger>Select Tool>MPLAB ICD2
MPLAB C18 C Debugger>Connect Configure>Configuration Bits Watchdog timer Low Voltage Programming XTBackground Debugging
MPLAB C18 C Debugger>Setting Program Debugger>Program Output
MPLAB C18 C Debugger>Run Run
MPLAB C18 C