diff --git a/README.txt b/README.txt
index 22a42dd..efbce61 100644
--- a/README.txt
+++ b/README.txt
@@ -108,6 +108,7 @@ The following MCU's and configurations have been tested:
* PIC24FJ64GB002
* PIC24FJ256DA206
* PIC18F46J50 - PIC18F Starter Kit
+ * PIC18F87J50
* PIC16F1459
* PIC16F1454 - similar to PIC16F1459
diff --git a/apps/cdc_acm/MPLAB.X/nbproject/configurations.xml b/apps/cdc_acm/MPLAB.X/nbproject/configurations.xml
index ea51165..a71476c 100644
--- a/apps/cdc_acm/MPLAB.X/nbproject/configurations.xml
+++ b/apps/cdc_acm/MPLAB.X/nbproject/configurations.xml
@@ -1087,6 +1087,177 @@
+
+
+ localhost
+ PIC18F87J50
+
+
+ ICD3PlatformTool
+ XC8
+ 1.31
+ 2
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ false
+
+ false
+
+ false
+ false
+ false
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
localhost
diff --git a/apps/cdc_acm/main.c b/apps/cdc_acm/main.c
index 5fab94b..dc001fc 100644
--- a/apps/cdc_acm/main.c
+++ b/apps/cdc_acm/main.c
@@ -55,6 +55,25 @@ _CONFIG3(WPFP_WPFP255 & SOSCSEL_SOSC & WUTSEL_LEG & ALTPMP_ALPMPDIS & WPDIS_WPDI
#pragma config IOL1WAY = OFF
#pragma config WPDIS = OFF /* This pragma seems backwards */
+#elif _18F87J50
+#pragma config PLLDIV = 3 /* 3 = Divide by 3. 12MHz crystal => 4MHz */
+#pragma config XINST = OFF
+#pragma config WDTEN = OFF
+#pragma config WDTPS = 32768
+#pragma config CPUDIV = OSC1
+#pragma config IESO = OFF
+#pragma config FCMEN = OFF
+#pragma config FOSC = HSPLL
+#pragma config CP0 = OFF
+#pragma config EASHFT = ON
+#pragma config MODE = MM
+#pragma config BW = 16
+#pragma config WAIT = OFF
+#pragma config CCP2MX = DEFAULT
+#pragma config ECCPMX = DEFAULT
+#pragma config PMPMX = DEFAULT
+#pragma config MSSPMSK = MSK7
+
#elif _16F1459
#pragma config FOSC = INTOSC
#pragma config WDTE = OFF
@@ -131,7 +150,7 @@ int main(void)
unsigned int pll_startup_counter = 600;
CLKDIVbits.PLLEN = 1;
while(pll_startup_counter--);
-#elif _18F46J50
+#elif defined(_18F46J50) || defined(_18F87J50)
unsigned int pll_startup = 600;
OSCTUNEbits.PLLEN = 1;
while (pll_startup--)
diff --git a/apps/hid_composite/MPLAB.X/nbproject/configurations.xml b/apps/hid_composite/MPLAB.X/nbproject/configurations.xml
index bb10b9b..e43ea3b 100644
--- a/apps/hid_composite/MPLAB.X/nbproject/configurations.xml
+++ b/apps/hid_composite/MPLAB.X/nbproject/configurations.xml
@@ -1004,6 +1004,171 @@
+
+
+ localhost
+ PIC18F87J50
+
+
+ ICD3PlatformTool
+ XC8
+ 1.12
+ 2
+
+
+
+
+
+
+
+ false
+
+
+
+
+ false
+
+ false
+
+ false
+ false
+ false
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
localhost
diff --git a/apps/hid_composite/main.c b/apps/hid_composite/main.c
index a85a9a0..fd5da2c 100644
--- a/apps/hid_composite/main.c
+++ b/apps/hid_composite/main.c
@@ -55,6 +55,25 @@ _CONFIG3(WPFP_WPFP255 & SOSCSEL_SOSC & WUTSEL_LEG & ALTPMP_ALPMPDIS & WPDIS_WPDI
#pragma config IOL1WAY = OFF
#pragma config WPDIS = OFF /* This pragma seems backwards */
+#elif _18F87J50
+#pragma config PLLDIV = 3 /* 3 = Divide by 3. 12MHz crystal => 4MHz */
+#pragma config XINST = OFF
+#pragma config WDTEN = OFF
+#pragma config WDTPS = 32768
+#pragma config CPUDIV = OSC1
+#pragma config IESO = OFF
+#pragma config FCMEN = OFF
+#pragma config FOSC = HSPLL
+#pragma config CP0 = OFF
+#pragma config EASHFT = ON
+#pragma config MODE = MM
+#pragma config BW = 16
+#pragma config WAIT = OFF
+#pragma config CCP2MX = DEFAULT
+#pragma config ECCPMX = DEFAULT
+#pragma config PMPMX = DEFAULT
+#pragma config MSSPMSK = MSK7
+
#elif _16F1459
#pragma config FOSC = INTOSC
#pragma config WDTE = OFF
@@ -118,7 +137,7 @@ int main(void)
unsigned int pll_startup_counter = 600;
CLKDIVbits.PLLEN = 1;
while(pll_startup_counter--);
-#elif _18F46J50
+#elif _18F46J50 || _18F87J50
unsigned int pll_startup = 600;
OSCTUNEbits.PLLEN = 1;
while (pll_startup--)
@@ -369,4 +388,4 @@ void interrupt high_priority isr()
#error need to make ISR
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/apps/hid_mouse/MPLAB.X/nbproject/configurations.xml b/apps/hid_mouse/MPLAB.X/nbproject/configurations.xml
index bf06841..6b4951b 100644
--- a/apps/hid_mouse/MPLAB.X/nbproject/configurations.xml
+++ b/apps/hid_mouse/MPLAB.X/nbproject/configurations.xml
@@ -527,6 +527,113 @@
+
+
+ localhost
+ PIC18F87J50
+
+
+ ICD3PlatformTool
+ XC8
+ 1.12
+ 2
+
+
+
+
+
+
+
+ false
+
+
+
+
+ false
+
+ false
+
+ false
+ false
+ false
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
localhost
diff --git a/apps/hid_mouse/main.c b/apps/hid_mouse/main.c
index d23d3f6..9262047 100644
--- a/apps/hid_mouse/main.c
+++ b/apps/hid_mouse/main.c
@@ -55,6 +55,25 @@ _CONFIG3(WPFP_WPFP255 & SOSCSEL_SOSC & WUTSEL_LEG & ALTPMP_ALPMPDIS & WPDIS_WPDI
#pragma config IOL1WAY = OFF
#pragma config WPDIS = OFF /* This pragma seems backwards */
+#elif _18F87J50
+#pragma config PLLDIV = 3 /* 3 = Divide by 3. 12MHz crystal => 4MHz */
+#pragma config XINST = OFF
+#pragma config WDTEN = OFF
+#pragma config WDTPS = 32768
+#pragma config CPUDIV = OSC1
+#pragma config IESO = OFF
+#pragma config FCMEN = OFF
+#pragma config FOSC = HSPLL
+#pragma config CP0 = OFF
+#pragma config EASHFT = ON
+#pragma config MODE = MM
+#pragma config BW = 16
+#pragma config WAIT = OFF
+#pragma config CCP2MX = DEFAULT
+#pragma config ECCPMX = DEFAULT
+#pragma config PMPMX = DEFAULT
+#pragma config MSSPMSK = MSK7
+
#elif _16F1459
#pragma config FOSC = INTOSC
#pragma config WDTE = OFF
@@ -98,7 +117,7 @@ int main(void)
unsigned int pll_startup_counter = 600;
CLKDIVbits.PLLEN = 1;
while(pll_startup_counter--);
-#elif _18F46J50
+#elif defined(_18F46J50) || defined(_18F87J50)
unsigned int pll_startup = 600;
OSCTUNEbits.PLLEN = 1;
while (pll_startup--)
@@ -318,4 +337,4 @@ void interrupt high_priority isr()
#error need to make ISR
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/usb/src/usb_hal.h b/usb/src/usb_hal.h
index eb9a42f..1f8e3e9 100644
--- a/usb/src/usb_hal.h
+++ b/usb/src/usb_hal.h
@@ -285,7 +285,7 @@ struct buffer_descriptor {
#define BDN_LENGTH(REG) (REG.BDnCNT)
#endif
-#ifdef _18F46J50
+#if defined(_18F46J50) || defined(_18F87J50)
#define BD_ADDR 0x400
//#undef BUFFER_ADDR
#else