More information would be helpful.
Are you trying to run the CPU core at 40MHz, and clock the USB module from
the same oscillator?
Or are you not using the USB module, and just trying to configure the PIC to
run on your 40MHz crystal?
Is this a 40MHz crystal (I.E. one requiring parallel caps) or is it a 40MHz TTL
clock oscillator?
Bookmarks