As CocaColaKid said... 18F's MUST use the MPASM Assembler.
Here is an EXAMPLE (for PIC18F2420) of the instructions that can be included at the start of your PBP program...
Here is an extract from the P18F2420.INC file in the MPLAB MPASM Suite subdirectory... note how (1) The ones needed have been copied from the INC file and inserted into the CONFIG statement.... and (2) for detailed explaination of each feature, refer to the DATASHEET - but I mustn't say that because I'll get flamed, so instead direct your queries to various members of the forum who'll read the Datasheet for you...Code:' ' PIC Defines for PIC18F2420 ' ========================== @ __CONFIG _CONFIG1H, _IESO_OFF_1H & _FCMEN_OFF_1H & _OSC_INTIO67_1H ' Oscillator Switch-over Disabled ' Fail-Safe clock Monitor Disabled ' _OSC_INTIO67_1H Set for Internal Oscillator RA6 & RA7 Enabled @ __CONFIG _CONFIG2L, _BOREN_ON_2L & _PWRT_ON_2L & _BORV_0_2L ' Brown-Out Reset Enabled ' Power-On Timer Enabled ' Brown-Out Trip set to 4.2v @ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H ' WatchDog is ON ' Watchdog Postscaler set to 1:128 @ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_PORTC_3H ' MCLR is OFF (internal) ' PortB 4:0 is digital on Reset ' CCP2 is Multiplexed with PortC.1 @ __CONFIG _CONFIG4L, _STVREN_ON_4L & _XINST_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L ' Stack Under/Overflow will Reset System ' Enhanced CPU Addressing Disabled ' Low-Voltage Programming is OFF ' DEBUG is Disabled @ __CONFIG _CONFIG5L, _CP1_ON_5L & _CP0_ON_5L ' All Code Protect @ __CONFIG _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H ' EEPROM is Code Protected ' Boot Block code is Code Protected
You will need to modify the 18F2420.INC file located in your PBP directory to something like this... (remembering to backup the original)...Code:;----- CONFIG1H Options -------------------------------------------------- _OSC_LP_1H EQU H'F0' ; LP oscillator _OSC_XT_1H EQU H'F1' ; XT oscillator _OSC_HS_1H EQU H'F2' ; HS oscillator _OSC_RC_1H EQU H'F3' ; External RC oscillator, CLKO function on RA6 _OSC_EC_1H EQU H'F4' ; EC oscillator, CLKO function on RA6 _OSC_ECIO6_1H EQU H'F5' ; EC oscillator, port function on RA6 _OSC_HSPLL_1H EQU H'F6' ; HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1) _OSC_RCIO6_1H EQU H'F7' ; External RC oscillator, port function on RA6 _OSC_INTIO67_1H EQU H'F8' ; Internal oscillator block, port function on RA6 and RA7 _OSC_INTIO7_1H EQU H'F9' ; Internal oscillator block, CLKO function on RA6, port function on RA7 _FCMEN_OFF_1H EQU H'BF' ; Fail-Safe Clock Monitor disabled _FCMEN_ON_1H EQU H'FF' ; Fail-Safe Clock Monitor enabled _IESO_OFF_1H EQU H'7F' ; Oscillator Switchover mode disabled _IESO_ON_1H EQU H'FF' ; Oscillator Switchover mode enabled ;----- CONFIG2L Options -------------------------------------------------- _PWRT_ON_2L EQU H'FE' ; PWRT enabled _PWRT_OFF_2L EQU H'FF' ; PWRT disabled _BOREN_OFF_2L EQU H'F9' ; Brown-out Reset disabled in hardware and software _BOREN_ON_2L EQU H'FB' ; Brown-out Reset enabled and controlled by software (SBOREN is enabled) _BOREN_NOSLP_2L EQU H'FD' ; Brown-out Reset enabled in hardware only and disabled in Sleep mode (SBOREN is disabled) _BOREN_SBORDIS_2L EQU H'FF' ; Brown-out Reset enabled in hardware only (SBOREN is disabled) _BORV_0_2L EQU H'E7' ; Maximum setting _BORV_1_2L EQU H'EF' ; _BORV_2_2L EQU H'F7' ; _BORV_3_2L EQU H'FF' ; Minimum setting ;----- CONFIG2H Options -------------------------------------------------- _WDT_OFF_2H EQU H'FE' ; WDT disabled (control is placed on the SWDTEN bit) _WDT_ON_2H EQU H'FF' ; WDT enabled _WDTPS_1_2H EQU H'E1' ; 1:1 _WDTPS_2_2H EQU H'E3' ; 1:2 _WDTPS_4_2H EQU H'E5' ; 1:4 _WDTPS_8_2H EQU H'E7' ; 1:8 _WDTPS_16_2H EQU H'E9' ; 1:16 _WDTPS_32_2H EQU H'EB' ; 1:32 _WDTPS_64_2H EQU H'ED' ; 1:64 _WDTPS_128_2H EQU H'EF' ; 1:128 _WDTPS_256_2H EQU H'F1' ; 1:256 _WDTPS_512_2H EQU H'F3' ; 1:512 _WDTPS_1024_2H EQU H'F5' ; 1:1024 _WDTPS_2048_2H EQU H'F7' ; 1:2048 _WDTPS_4096_2H EQU H'F9' ; 1:4096 _WDTPS_8192_2H EQU H'FB' ; 1:8192 _WDTPS_16384_2H EQU H'FD' ; 1:16384 _WDTPS_32768_2H EQU H'FF' ; 1:32768 ;----- CONFIG3H Options -------------------------------------------------- etc etc etc
This is because the MPASM Assembler cannot handle CONFIG conflicts....Code:;**************************************************************** ;* 18F2420.INC * ;* * ;* By : Leonard Zerman, Jeff Schmoyer * ;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. * ;* All Rights Reserved * ;* Date : 12/31/04 * ;* Version : 2.46 * ;* Notes : Butchered by Melanie * ;**************************************************************** NOLIST ifdef PM_USED LIST "Error: PM does not support this device. Use MPASM." NOLIST else LIST LIST p = 18F2420, r = dec, w = -311, f = inhx32 INCLUDE "P18F2420.INC" ; MPASM Header NOLIST endif LIST EEPROM_START EQU 0F00000h BLOCK_SIZE EQU 8
Finally, to make it all compile (and remembering to ensure you have a PATH embedded pointing to your MPASM directory), you can compile with a command line like...
PBPW -p18F2420 MyProgram -ampasmwin -v
Hey presto... it'll compile and embed all your selected CONFIG directives into the resultant HEX file (and as a bonus MPASM displays a lovely green progress bar that just makes you feel all warm and fuzzy inside).
You may get some warning messages (they're just Warnings and NOT Errors) from MPASM that the CONFIG statements have been depricated, but a search on this forum will reveal how to suppress those.




Bookmarks