PDA

View Full Version : #config length ?



Ruben Pena
- 13th August 2011, 22:40
Dear friends:

In PBP3,all pics are assembled with MPLAB,
EXAMPLE:

For the PIC 16F886 I am using

#CONFIG
__config _CONFIG1,_INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_ON
__config _CONFIG2, _BOR21V
#ENDCONFIG
It works OK,but the first line excceds the 80 chars for line.
Can I separate the second part "_LVP_OFF & _CP_ON " maybe with
another line as:
__CONFIG _CONFIG1,_LVP_OFF & _CP_ON ?
I tried that ,but it generates a compiler error.

The new reference manual states the fuses separated for the PICS18...
This works for the PIC16 too ?

Thanks in advance...
Ruben de la Pena Valdes.

cncmachineguy
- 14th August 2011, 00:37
I count 76, are you sure that's the error?

mister_e
- 14th August 2011, 01:19
You can use something like that


#CONFIG
CFG1 = _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF
CFG11 = _LVP_OFF & _CP_ON

__config _CONFIG1, CFG1 & CFG11
__config _CONFIG2, _BOR21V
#ENDCONFIG

mister_e
- 14th August 2011, 01:21
cnc, it's not an error, it's just over the IDE gutter (which you can still move to whatever else but 80).

Heckler
- 14th August 2011, 16:57
I would like to know the same thing... That is, how can one break long "__CONFIG" lines into shorter lines?

Below is an example of how to compile your program for two different PIC's, 16F1828 and 16F690. It works NOW... but getting the config statements right cost me a lot of time.

Specifically the fact that "__CONFIG _CONFIG1," works for 16F1828 and "__CONFIG" (no comma) had to be used for the 16F690.

Is the fact that some PIC's require a comma in the config line and some do not determined by MPLAB??


#IF __PROCESSOR__ = "16F1828"
#CONFIG
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_OFF & _MCLRE_OFF & _CP_ON & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_25 & _LVP_OFF
#endconfig
#else
#IF __PROCESSOR__ = "16F690"
#CONFIG
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _CP_ON & _CPD_OFF & _BOD_OFF & _IESO_OFF & _FCMEN_OFF
#endconfig
#ELSE
#ERROR "Program does not support " + __PROCESSOR__
#ENDIF
#endif

#msg "compiling for target " + __PROCESSOR__

Darrel Taylor
- 14th August 2011, 17:55
If the chip only has one config word, you don't specify the word's name because it doesn't have one.
For chips with more than one config word, you must specify the word with _CONFIG1 or _CONFIG2 etc.

If you like commenting everthing really well, you can do the configs like this ...

#if __PROCESSOR__ = "16F1828"
#config
CFG = _FOSC_INTOSC ; Oscillator
CFG=CFG& _WDTE_ON ; Watch Dog Timer
CFG=CFG& _PWRTE_OFF ; Power-on Timer
CFG=CFG& _MCLRE_OFF ; Master Clear Reset
CFG=CFG& _CP_ON ; Code Protect
CFG=CFG& _CPD_OFF ; EEPROM Data Protect
CFG=CFG& _BOREN_OFF ; Brown-out Detect
CFG=CFG& _CLKOUTEN_OFF ; FOSC/4 Output
CFG=CFG& _IESO_OFF ; Internal External Switchover
CFG=CFG& _FCMEN_OFF ; Fail-Safe Clock Monitor
__CONFIG _CONFIG1, CFG

CFG = _WRT_OFF ; Flash table writes
CFG=CFG& _PLLEN_OFF ; 4xPLL OSC multiplier
CFG=CFG& _STVREN_OFF ; Stack Over/Underflow
CFG=CFG& _BORV_25 ; Brown-out voltage
CFG=CFG& _LVP_OFF ; Low Voltage Programming
__CONFIG _CONFIG2, CFG
#endconfig
#else
#IF __PROCESSOR__ = "16F690"
#config
CFG = _INTRC_OSC_NOCLKOUT ; Oscillator
CFG=CFG& _WDT_ON ; Watch Dog Timer
CFG=CFG& _PWRTE_OFF ; Power-on Timer
CFG=CFG& _MCLRE_OFF ; Master Clear Reset
CFG=CFG& _CP_ON ; Code Protect
CFG=CFG& _CPD_OFF ; EEPROM Data Protect
CFG=CFG& _BOD_OFF ; Brown-out Detect
CFG=CFG& _IESO_OFF ; Internal External Switchover
CFG=CFG& _FCMEN_OFF ; Fail-Safe Clock Monitor
__CONFIG CFG
#endconfig
#else
#error "Program does not support " + __PROCESSOR__
#endif
#endif
#msg "compiling for target " + __PROCESSOR__

Ruben Pena
- 14th August 2011, 20:35
Hi:
Thanks Steve, it works now !.
Greetings...
Ruben de la Pena Valdes.

mister_e
- 15th August 2011, 01:12
Still doable the long way, still easy though


ASM

__CONFIG _CONFIG1, B'11111101010100'
; 1------------- CP: Code Protection off
; -1------------ CPMX: CCP1 on RB0
; --1----------- DEBUG: Disabled. RB<7:6> are general purpose i/o
; ---11--------- WRT: Write Protection off
; -----1-------- CPD: Code Protection off
; ------0------- LVP: Disabled. RB3 Is General I/O
; -------1------ BOREN: Enable Brown Out Reset
; --------0----- MCLRE: Disable MCLR, RA5 Is digital I/O
; ----------0--- PWRTE: Enable Power-Up Timer
; -----------1-- WDTEN: Enable Watch Dog Timer
; ---------1--00 FOSC: INTRC, NOCLKOUT

__CONFIG _CONFIG2, b'11111111111100'
; xxxxxxxxxxxx-- unimplemented
; ------------0- IESO: Disable Internal/External Swichover
; -------------0 FCMEN: Disable Fail-Safe Clock Monitor

ENDASM Not too hot with that method, but neat