= > ; > ; Configuration Bits > ; IN MY BOOKS IT SAYS HERE > = > __CONFIG H'3FF0' ;SETS LP > OSC, WDT OFF, PUT ON, > = > ;CODE PROTECTION DISABLED > ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > = > = > = > ********************************************************************* > VELLEMAN / MICROCHIP THEN > CONTINUES WITH > = > ********************************************************************* > = > = > _BODEN_ON EQU H'3FFF' > _BODEN_OFF EQU H'3FBF' > _CP_ALL EQU H'03FF' > _CP_75 EQU H'17FF' > _CP_50 EQU H'2BFF' > _CP_OFF EQU H'3FFF' > _DATA_CP_ON EQU H'3EFF' > _DATA_CP_OFF EQU H'3FFF' > _PWRTE_OFF EQU H'3FFF' > _PWRTE_ON EQU H'3FF7' > _WDT_ON EQU H'3FFF' > _WDT_OFF EQU H'3FFB' > _LVP_ON EQU H'3FFF' > _LVP_OFF EQU H'3F7F' > _MCLRE_ON EQU H'3FFF' > _MCLRE_OFF EQU H'3FDF' > _ER_OSC_CLKOUT EQU H'3FFF' > _ER_OSC_NOCLKOUT EQU H'3FFE' > _INTRC_OSC_CLKOUT EQU H'3FFD' > _INTRC_OSC_NOCLKOUT EQU H'3FFC' > _EXTCLK_OSC EQU H'3FEF' > _LP_OSC EQU H'3FEC' > _XT_OSC EQU H'3FED' > _HS_OSC EQU H'3FEE' > = > LIST > = To sum things up: The configuration register is a location in program memory that configures = different aspects of the chip. It has to be set during programming of the c= hip = and can't be changed by code running in the chip. Different PICs have different configuration settings and to know which ones = there are you need to read the datasheet. The configuration bits can set wh= at = type of oscillator circuit is used, if the watchdog timer is used or not, i= f = the brown out detector is used or not, if and how the chip is code protecte= d = and so on. the __CONFIG directive tells the assembler that the word following is going= to = be placed at the location for the configuration register. = This word can be written as a constant in any radix (like H'3FF0') but then= you = need to know which bits means what and build your word from that. In your c= ode = above, the programmer has done this and indicated with a comment what the = configuration register with this value means. But this is kind of dangerous = since you can change the configuration value without changing the comment. To make things easier for the programmer and anybody that is going to read = the = source code, the include file for the different PIC processors contains a s= et = of macros that lets the programmer use more or less readable text (self = commenting) to define the configuration word. It has been chosen that the macros for the different configuration bits sho= uld = be ANDed together in order to make a complete configuration word. I'm not q= uite = sure why but doing like this automatically turns on any configuration bits = that = has its corresponding macro omitted in the __CONFIG directive. As you can see in the include file, there are two or more macros for every = different configuration function (which represents one or more bits in the = configuration word) and all possible combinations for one configuration = function can be selected using one of the macros for that configuration = function. For example the macro _WDT_ON says that this is for the watchdog = function and ON is one of the settings for this configuration function. Sin= ce = the watchdog only has one bit in the configuration register there are two = macros for it - one for turning it on and one for turning it off. To make sure you get the correct configuration word you pick ONE configurat= ion = setting macro for each configuration function from the include file and AND = them together as the configuration word for the __CONFIG directive in the = assembler file. So for the above include file you pick one of the macros fo= r = _BODEN, _CP, _DATA_CP, _PWRTE, _WDT, _LVP, _MCLRE, _ER_OSC, _INTRC_OSC and = one = of the four oscillator settings. /Ruben =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D Ruben J=F6nsson AB Liros Electronic Box 9124, 200 39 Malm=F6, Sweden TEL INT +46 40142078 FAX INT +46 40947388 ruben@pp.sbbs.se =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist