Hello,
I've just started to use a new PIC which I cannot get to work at all, I suspect it has to do with the OSC setting or the PPS setup.
To start with I'm just trying to flash a LED on RA3, in the long term I'll have TX on RA0, RX on RA1, and PWM on RA3.
Any help will be greatly appreciated!
Code:
' PIC16F18313
' +---------:_:---------:
' 5v0 -> 1 : VDD VSS : 8 <- GND
' <> 2 : RA5/AN5 AN0/RA0 : 7 <> PGD -> TX
' <> 3 : RA4/AN4 AN1/RA1 : 6 <> PGC -> RX
' PWM <- VPP -> 4 : RA3/MCLRn AN2/RA2 : 5 <>
' +---------------------+
' DIP-8
' DEVICE CONFIGURATION
#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
__config _CONFIG2, _MCLRE_OFF & _PWRTE_ON & _WDTE_OFF & _LPBOREN_OFF & _BOREN_OFF & _BORV_LOW & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
__config _CONFIG3, _WRT_OFF & _LVP_OFF
__config _CONFIG4, _CP_OFF & _CPD_OFF
#ENDCONFIG
' DEFINEs
DEFINE OSC 8 ' Internal 8MHz
' Pin ALIASES
' CONSTANTS
' VARIABLES
' INITIALIZE REGISTERS
OSCCON1 = 100000 ' NOSC = 110, NDIV = 0000
'OSCCON2 = 100000 ' COSC = 110, CDIV = 0000
OSCCON3 = 0
OSCFRQ = 00 ' HFFRQ 8MHz
ADCON0 = 0 ' Disable ADC
ANSELA = 0 ' Set to Digital Port A
' ANSELC = 0 ' Set to Digital Port C (16F18323 only)
ODCONA = 0 ' set output as push-pull (OD by default)
SLRCONA = 0 ' set output slew rate to maximum
CM1CON0 = 0 ' Disable Comparator
' CM2CON0 = 0 ' Disable Comparator (16F18323 only)
' WPUA = 000001 ' Set Weak Pull-ups
' OPTION_REG.7 = 0 ' Enable Weak Pull-up for Temp Sensor so check works
TRISA = 000000 ' Set ports as outputs
' PROGRAM Start
MAIN:
LATA.3 = 1
PAUSE 1000
LATA.3 = 0
PAUSE 1000
GOTO MAIN
Bookmarks