config

Thread Starter

sasek

Joined Jan 3, 2010
64
hai all,

thank 4 view,

i beginer in mplab, could some one help me figure wat means by __CONFIG, if any link that related to my problem????? i really appreciate i u can help me.



thanks lot............:)
 

Markd77

Joined Sep 7, 2009
2,806
Search for "configuration word" in the datasheet for your processor
Assuming you are using assembler, there should be a section at the start of your program like this:


Rich (BB code):
   list    p=16F628a
    radix    hex
    title "usart7seg"
        #include <p16f628a.inc>
    __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _LVP_ON
Also look at the .inc file for your processor which is in:
c:\program files\Microchip\MPASM Suite

For a code template go to:
c:\program files\Microchip\MPASM Suite\Template\Code
 

t06afre

Joined May 11, 2009
5,934
the __config is for setting the configuration bits in the CPU. You will find a section in the data sheet describing this. If they are not set in a proper way the uC will not work at all. The configuration bits will vary from different Microchip uCs. In the .inc you will find a list describing the options valid for a particular uC. The different settings are combined by logical and function. The final configuration word is then written into the config register then programmed. You may also set the configuration bit in MPLAB. In the toolbar goto configuration->configuration bits.
As an example
the code
Rich (BB code):
#include <p16F690.inc>
     __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
will be equal to this setting in MPLAB.
PS. Do NOT set the code protect option on if you want to reprogram your uC:eek:
 

Attachments

Thread Starter

sasek

Joined Jan 3, 2010
64
thanks Markd77 & t06afre

really2 appreciate u all help, in addtion how i can know which __CONFIG code suitable for which PIC. i.e for PIC16f877A config code is 0x3F32. if i want use another PIC what code should i used..............


thanks guy 4 helping me explore this PIC............... :)
 

t06afre

Joined May 11, 2009
5,934
You have two ways.
1) open the chip include file, and take a look at the settings described in this file. And the settings together
2) You may skip this and use MPLAB. In the toolbar goto configuration->configuration bits.
The setting may vary. You must read the data sheet and find the correct setting for your application
Example from the p16F690.inc file
Rich (BB code):
;==========================================================================
;
; Configuration Bits
;
;==========================================================================
 
_FCMEN_ON EQU H'3FFF'
_FCMEN_OFF EQU H'37FF'
_IESO_ON EQU H'3FFF'
_IESO_OFF EQU H'3BFF'
_BOR_ON EQU H'3FFF'
_BOR_NSLEEP EQU H'3EFF'
_BOR_SBODEN EQU H'3DFF'
_BOR_OFF EQU H'3CFF'
_CPD_ON EQU H'3F7F'
_CPD_OFF EQU H'3FFF'
_CP_ON EQU H'3FBF'
_CP_OFF EQU H'3FFF'
_MCLRE_ON EQU H'3FFF'
_MCLRE_OFF EQU H'3FDF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FEF'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FF7'
_LP_OSC EQU H'3FF8'
_XT_OSC EQU H'3FF9'
_HS_OSC EQU H'3FFA'
_EC_OSC EQU H'3FFB'
_INTRC_OSC_NOCLKOUT EQU H'3FFC'
_INTRC_OSC_CLKOUT EQU H'3FFD'
_EXTRC_OSC_NOCLKOUT EQU H'3FFE'
_EXTRC_OSC_CLKOUT EQU H'3FFF'
_INTOSCIO EQU H'3FFC'
_INTOSC EQU H'3FFD'
_EXTRCIO EQU H'3FFE'
_EXTRC EQU H'3FFF'
 

AlexR

Joined Jan 16, 2008
732
Read the data sheet for your chip! Pay special attention to the section "Special features of the CPU/Configuration bits". It lists all the configuration bits and tells you what each bit does. You will find it near the end of the data sheet, just before the electrical specifications.
 

Markd77

Joined Sep 7, 2009
2,806
There are many valid settings for each PIC. I'm not sure where the 0x3F32 value came from, but there are many other possibilities.
which __CONFIG code suitable for which PIC. i.e for PIC16f877A config code is 0x3F32. if i want use another PIC what code should i used..............
If you are not modifying some code that already has __CONFIG 0x3F32 it is much easier to just use the .....&......& format as in my and t06afre's examples. Just pick one option from each section of the list in the .inc file.
 

Thread Starter

sasek

Joined Jan 3, 2010
64
ok thanks guys

im slow in this, thanks for your patience, now i know where to find config bit

but for pic26f877a they off the code protection, code protection stand for what?

thanks for helping me.....im still new hehe.......:)
 

t06afre

Joined May 11, 2009
5,934
When code-protected,the device programmer can no longer access data and/or program memory. You will NOT be able to reprogram your PIC if you set this option:eek:. But the CPU will function as normal. The program memory and EEPROM memory do have separate config bits for protection When the device EEPROM memory is code protected, the CPU may continue to read and write the data EEPROM memory.
It is NO undo for this setting. So do not toy with it, leave it OFF. This setting is for manufacturer/other that will protect the program code, as it is intellectual property
 
Top