1. sasek

    Thread Starter Member

    Jan 3, 2010
    64
    0
    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............:)
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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:


    Code ( (Unknown Language)):
    1.    list    p=16F628a
    2.     radix    hex
    3.     title "usart7seg"
    4.         #include <p16f628a.inc>
    5.     __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
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
    Code ( (Unknown Language)):
    1.  
    2. #include <p16F690.inc>
    3.      __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
    4.  
    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:
     
  4. sasek

    Thread Starter Member

    Jan 3, 2010
    64
    0
    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............... :)
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
    Code ( (Unknown Language)):
    1.  
    2. ;==========================================================================
    3. ;
    4. ; Configuration Bits
    5. ;
    6. ;==========================================================================
    7.  
    8. _FCMEN_ON EQU H'3FFF'
    9. _FCMEN_OFF EQU H'37FF'
    10. _IESO_ON EQU H'3FFF'
    11. _IESO_OFF EQU H'3BFF'
    12. _BOR_ON EQU H'3FFF'
    13. _BOR_NSLEEP EQU H'3EFF'
    14. _BOR_SBODEN EQU H'3DFF'
    15. _BOR_OFF EQU H'3CFF'
    16. _CPD_ON EQU H'3F7F'
    17. _CPD_OFF EQU H'3FFF'
    18. _CP_ON EQU H'3FBF'
    19. _CP_OFF EQU H'3FFF'
    20. _MCLRE_ON EQU H'3FFF'
    21. _MCLRE_OFF EQU H'3FDF'
    22. _PWRTE_OFF EQU H'3FFF'
    23. _PWRTE_ON EQU H'3FEF'
    24. _WDT_ON EQU H'3FFF'
    25. _WDT_OFF EQU H'3FF7'
    26. _LP_OSC EQU H'3FF8'
    27. _XT_OSC EQU H'3FF9'
    28. _HS_OSC EQU H'3FFA'
    29. _EC_OSC EQU H'3FFB'
    30. _INTRC_OSC_NOCLKOUT EQU H'3FFC'
    31. _INTRC_OSC_CLKOUT EQU H'3FFD'
    32. _EXTRC_OSC_NOCLKOUT EQU H'3FFE'
    33. _EXTRC_OSC_CLKOUT EQU H'3FFF'
    34. _INTOSCIO EQU H'3FFC'
    35. _INTOSC EQU H'3FFD'
    36. _EXTRCIO EQU H'3FFE'
    37. _EXTRC EQU H'3FFF'
    38.  
     
  6. sasek

    Thread Starter Member

    Jan 3, 2010
    64
    0
    thanks again t06afre

    could u explain with more detail.......plz.... :)
     
  7. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    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.
     
  8. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    There are many valid settings for each PIC. I'm not sure where the 0x3F32 value came from, but there are many other possibilities.
    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.
     
  9. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Sorry can not help you unless you tell us more about what you have done so far and why you struggle. you have to read the data sheet, and the section pointed to by AlexR to understand this.
     
  10. sasek

    Thread Starter Member

    Jan 3, 2010
    64
    0
    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.......:)
     
  11. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
  12. sasek

    Thread Starter Member

    Jan 3, 2010
    64
    0
    oooooo......

    i will never2 play with code protected
     
  13. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    You cannot turn off the code protected PIC bit, you must erase the entire PIC to reset the config bit.
     
  14. sasek

    Thread Starter Member

    Jan 3, 2010
    64
    0
    thanks it some new knowledge i leran from u
     
  15. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Is that true for all PIC flash type uCs? I have not tested it. As I was afraid those bits were fusebits.
     
Loading...