PDA

View Full Version : Pic18f14k50



JoeyWallice
- 15th October 2012, 08:40
Hi

I am looking for the Config Settings for a Pic 18F14K50 for internal ossification at 4mhz and a simple program to turn an led on and off at PB.5

I am sure I will be able to take if from there

Please Thanks

LinkMTech
- 15th October 2012, 16:18
Untested using PBPX 3.0.1.4 but should get you started and hopefully not even more lost.



'************************************************* ***************
' Config files for PIC18F14K50 with internal 4MHz clock
#CONFIG
__CONFIG _CONFIG1L, _CPUDIV_NOCLKDIV_1L & _USBDIV_OFF_1L
__CONFIG _CONFIG1H, _FOSC_IRC_1H & _PLLEN_OFF_1H & _PCLKEN_ON_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRTEN_ON_2L & _BOREN_ON_2L & _BORV_19_2L
__CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _MCLRE_OFF_3H
__CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _BBSIZ_ON_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
__CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
__CONFIG _CONFIG5H, _CPB_OFF_5H
#ENDCONFIG
PORTA = %00000000 ' Turn off all PORTA
TRISA = %11111111 ' PORTA set to inputs
PORTB = %00000000 ' Turn off all PORTB
TRISB = %00000000 ' PORTB set to outputs
PORTC = %00000000 ' Turn off all PORTC
TRISC = %11111111 ' PORTC set for intputs
CM1CON0.7 = 0 ' Analog comparator #1 off
CM2CON0.7 = 0 ' Analog comparator #2 off
ADCON0.0 = 0 ' A/D module disabled
ADCON1 = 0 ' A/D references set to Vdd and Vss
ANSEL = 0 ' Turn Analog Register 1 OFF
ANSELH = 0 ' Turn Analog Register 2 OFF
CCP1CON = 0 ' Disables CCP module
TXSTA.5 = 0 ' EUSART transmitter disabled
RCSTA.7 = 0 ' EUSART serial port disabled

OSCCON = %01010110 ' Section 2.6 Oscillator Control of data sheet
CLEAR ' Set all registers to 0

DEFINE OSC 4

'================================================= ========================
' Variable Definitions
'================================================= ========================
LED VAR LATB.5 ' LED aliased to PORTB Latch register 5

'================================================= ========================
' Turn LED On/OFF @ 2Hz
'================================================= ========================
Main:
LED = 1 ' Turn LED ON
PAUSE 500 ' Wait 500ms
LED = 0 ' Turn LED OFF
PAUSE 500 ' Wait 500ms
GOTO Main

JoeyWallice
- 23rd October 2012, 11:13
Thanks Link