The Microchip loader expects your config settings to match the settings in
the C18 loader template. If they're different, it throws up this error.
I've recompiled the C18 USB framework files myself, for use with the 18F2550
or 18F4550. Here's what I did in Main.c;
Note this assumes a 20MHz external xtal.
Code:
#if defined(__18F4550)
#pragma config PLLDIV=5,CPUDIV=OSC1_PLL2,USBDIV=2,FOSC=HSPLL_HS,FCMEN=OFF,IESO=OFF
#pragma config VREGEN=ON,CCP2MX=ON,WDT=OFF,WDTPS=32768,PBADEN=OFF,PWRT=OFF,MCLRE=ON
#pragma config LPT1OSC=OFF,BOR=ON,BORV=2,STVREN=ON,LVP=OFF,ICPRT=OFF,XINST=OFF,DEBUG=OFF
#pragma config WRTB=ON
#else
// For 18F2550 (NOTE: Be sure to swap linker files for the USB PIC being used)
#pragma config PLLDIV=5,CPUDIV=OSC1_PLL2,USBDIV=2,FOSC=HSPLL_HS,FCMEN=OFF,IESO=OFF
#pragma config VREGEN=ON,CCP2MX=ON,WDT=OFF,WDTPS=32768,PBADEN=OFF,PWRT=OFF,MCLRE=ON
#pragma config LPT1OSC=OFF,BOR=ON,BORV=2,STVREN=ON,LVP=OFF,XINST=OFF,DEBUG=OFF
#pragma config WRTB=ON
#endif
Just be sure to swap linker files before recompiling.
Then in my PBP 18F4550.INC file I placed the same config settings in it.
Code:
INCLUDE "P18F4550.INC" ; MPASM Header
CONFIG PLLDIV=5,CPUDIV=OSC1_PLL2,USBDIV=2,FOSC=HSPLL_HS,FCMEN=OFF,IESO=OFF
CONFIG VREGEN=ON,CCP2MX=ON,WDT=OFF,WDTPS=32768,PBADEN=OFF,PWRT=OFF,MCLRE=ON
CONFIG LPT1OSC=OFF,BOR=ON,BORV=2,STVREN=ON,LVP=OFF,ICPRT=OFF,XINST=OFF,DEBUG=OFF
CONFIG WRTB=ON
I made a few other modifications to the C18 loader firmware. Mainly just to
change the USB loader status LED's to a different port when using the
18F2550.
In io_cfg.h;
Code:
/** L E D ***********************************************************/
#if defined(__18F4550)
#define mInitAllLEDs() LATD &= 0xF0; TRISD &= 0xF0;
#define mLED_1 LATDbits.LATD0
#define mLED_2 LATDbits.LATD1
#define mLED_3 LATDbits.LATD2
#define mLED_4 LATDbits.LATD3
#else
#define mInitAllLEDs() LATB &= 0xF0; TRISB &= 0xF0;
#define mLED_1 LATBbits.LATB0
#define mLED_2 LATBbits.LATB1
#define mLED_3 LATBbits.LATB2
#define mLED_4 LATBbits.LATB3
#endif
Bookmarks