32MHz internal
Config:
Code:
#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
__config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
__config _CONFIG5, _CP_OFF & _CPD_OFF
#ENDCONFIG
Oscillator:
Code:
DEFINE OSC 32
OSCCON1 = %01100010
' bit 7 n/a
' 6-4 NOSC New Oscillator Source Request bits
' 110 HFINTOSC
' 3-0 NDIV New Divider Selection Request bits
' 0010 Clock divider = 4
OSCCON3 = %00000000 ' Default values
OSCEN = %00000000 ' Default values
OSCFRQ = %00000110
' bit 7-3 n/a
' 2-0 HFFRQ Frequency Selection bits
' 110 32 MHz
OSCTUNE = %00000000 ' Default values
PPS pin definitions to use CCP3 and CCP4 on Ports D2 and D3 respectively:
Code:
PinD2 CON %011010 ' Datasheet table 13-2
PinD3 CON %011011
CCP3PPS = PinD2 ' CCP3 Peripheral input selection
CCP4PPS = PinD3 ' CCP4 Peripheral input selection
PeripheralCCP3 CON %001011 ' Datasheet table 13-3
PeripheralCCP4 CON %001100
RD2PPS = PeripheralCCP3 ' Pin D2 output source selection
RD3PPS = PeripheralCCP4 ' Pin D3 output source selection
HPWM on pins D2 and D3:
Code:
HPWM 3,160,1953 ' Sample Pulses
HPWM 4,180,1953
Thanks go to TimB and Top204 on the Proton forum (that's where I got the Config from):
https://protoncompiler.com/index.php?topic=528.0
Bookmarks