PDA

View Full Version : Proper Technique of Setting Config Values



Zebryk
- 3rd March 2015, 17:07
Hello,

What is the proper technique for setting configuration values?
The below works fine, but, being all in one line, it is hard to read vs the older style below it.


#CONFIG
__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _BOD_ON & _IESO_OFF & _FCMEN_OFF & _PWRTE_ON


#ENDCONFIG


'@ DEVICE PIC16F684
'@ DEVICE INTRC_OSC_NOCLKOUT
'@ DEVICE WDT_OFF
'@ DEVICE MCLR_OFF
'@ DEVICE BOD_ON
'@ DEVICE IESO_OFF
'@ DEVICE FCMEN_OFF
'@ DEVICE PWRT_ON

Thanks,

Archangel
- 3rd March 2015, 18:54
Darrel showed me to do it this way in PBP, not PBP3 :
16F690


@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
@MyConfig = MyConfig & _MCLRE_OFF & _BOR_OFF & _FCMEN_OFF & _IESO_OFF
@ __config MyConfig

HenrikOlsson
- 3rd March 2015, 20:38
What is the proper technique for setting configuration values?
The proper way is described in the manual and for a 16F part it IS the "one liner". Back in the day MELABS had their own assembler for which the @ DEVICE stuff you reference was used. PM is now obsolete and you need to use whatever Microchip dictates for their MPASM. The manual states:


Microchip determines the form and syntax of the actual configuration directives, and they are not consistent for different families of PIC microcontrollers.

So, with PBP3 and a 16F part you do it the one line way, for the 16F684:

#CONFIG
__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
#ENDCONFIG
Which, I suppose you could "extend" to what Arcangel is showing (not tested and IMHO more cluttered than the oneliner)

@MyConfig = _INTRC_OSC_NOCLKOUT
@MyConfig = MyConfig & _WDT_ON
@MyConfig = MyConfig & _MCLR_ON
@MyConfig = MyConfig & _CP_OFF

#CONFIG
__config MyConfig
#ENDCONFIG


For 18F parts it's more like the way it was with the PM assembler:

#config
CONFIG FOSC = HS
CONFIG WDTEN = OFF
CONFIG PWRT = ON
CONFIG BOREN = OFF
CONFIG PBADEN = OFF
CONFIG MCLRE = OFF
CONFIG LVP = OFF
CONFIG DEBUG = OFF
CONFIG XINST = OFF
#endconfig

/Henrik.

Archangel
- 3rd March 2015, 23:43
Reply: It IS more cluttered BUT for those who have both poor vision and do not use a wide
screen monitor it allows you to string
the configs across several lines . . .
And it IS tested, I use it on a regular basis. I have PBP3 but use PBP2.6c mostly because I use simpler PICs
and do not want to fritz with PBP3 s configs . . .

Zebryk
- 4th March 2015, 00:07
Well, I did ask but am disappointed.
Yes, that alternate method is even more cluttered and confusing.
Raises more rule questions than the awkward but more clearer one-liner.

Not being as sophisticated as you all, I strive for consistency in formatting,
hoping that anything "messy" has not been thought through yet by me.

Thanks!

rsocor01
- 4th March 2015, 02:10
Well, I did ask but am disappointed.
Yes, that alternate method is even more cluttered and confusing.
Raises more rule questions than the awkward but more clearer one-liner.

Not being as sophisticated as you all, I strive for consistency in formatting,
hoping that anything "messy" has not been thought through yet by me.

Thanks!

Well, you can always use the U2 Melabs programmer and the software that comes with it. It is very easy to use.

http://store.melabs.com/prod/u2/U2.html

7723

towlerg
- 4th March 2015, 18:03
If you you use the programmer to set the fuses, how do you remember what they were 3 months later?

George