I am trying to use a 20 MHz crystal with a PIC16F886. When I select the external HS crystal in various ways it does not work rather the PIC runs at 4 MHZ, even tho the define is for OSC 20. This is measurable by setting a delay for 100usec and having it instead be 500usec. It thinks it is using a 20MHz crystal to calculate the timing when it is instead using the internal 4MHz clock. Unless somehow the crystal is operating at exactly 4 MHz instead of 20MHz. It doesn't seem to be, actually doesn't seem to be running at all.

The circuit is built on a ground plane proto board and laid out carefully. I added 20k across the crystal input to I assume make it stop oscillating at all if it was but the execution is the same at 4 MHz, so I'm confident the crystal is not even part of the circuit now.

I've set the configuration bits in MPLAB to select HS oscillator without success. I set the OSCCON to %01101000 which is supposed to use bits FOSC 0-2 to set the oscillator choice.

I've tried various settings of #config...#endconfig and those don't work. But given how those are kind of mysterious I may be setting those wrong.
This is what I tried: __config1 _FOSC_HS & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _WRT_OFF

I also tried defining the config1 register to set it up to use the external crystal: DEFINE CONFIG1 $EFC2

Nothing works. The internal 8 MHz works just fine and the program executes as expected.

Honestly I've had more consternation trying to figure out the configuration process and getting that to work. That aspect of this software needs attention.