Looking to get a bit more speed out of an pre-existing circuit that uses a 16F873a (max 20MHz clock), did a search for faster pin-compatible or almost pin-compatible 28-pin 16F's. Decided on the 16F1782 (32MHz internal) and put it in the circuit.
But because of an error in my initial configuration, I discovered an undocumented mode: 80MHz clock from 20MHz external osc input on RA7/CLKIN, using the configuration below.
Code:
#CONFIG
__config _CONFIG1, _FOSC_HS & _CLKOUTEN_OFF & _WDTE_ON ;so using an external osc source, but also x4 PLL (OSCCON.7 =1)
__config _CONFIG2, _PLLEN_OFF
#ENDCONFIG
DEFINE OSC 20 'defines clock frequency = 20MHz, but since actually clocking at 80MHz, a lot of the PBP timing will be off by factor 4.
WDTCON = %00011010 '8 second watchdog
OSCCON = %11111000 'PLL x 4,
INTCON = 0 'disable interrupts,
ADCON0.0 = 0 'disables a-d converter
ANSELA = 0
ANSELB = 0
INLVLA = %00001111
DACCON0.7 = 0 ' Disable DAC
CM1CON0.7 = 0 ' Disable comparator 1
CM2CON0.7 = 0 ' Disable comparator 2
CM3CON0.7 = 0 ' Disable comparator 3
TRISA = %11011111
TRISB = %11100000
TRISC = %11110000
The x4 PLL is deriving the clock from the 20MHz external osc.
Obviously, this is overclocking and outside the design specification envelope. So not for production designs without extensive reputability, reliabilty, temperature range tolerance, lifetime endurance, EMI, etc. testing.
But good for hobby projects where you need a bit more speed from a 28-pin 16F!
It runs cool to the touch, so not an exorbitant current drain, but I have not measured the current drawn.
I have only used it in an pre-existing circuit that had an external 20MHz clock, not with a 20MHz HS crystal directly on the 16F1782. But that would probably work too. Have not tried it with sleep modes either.
Runs with 5V supply, have not tried with 3V, which would probably be more critical.
Bookmarks