configuration bits and their importance

Discussion in 'Embedded Systems and Microcontrollers' started by ect_09, Oct 15, 2014.

  1. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    Hello everybody,
    as you know am new with PIC18f452. i become successful to run LED Blinking code on hardware.although its was copy paste first time but i understand all the code and configuration bits but am confused in

    __CONFIG(1, OSCSDIS & HSPLL);

    __CONFIG(2, BORDIS & PWRTDIS & WDTDIS);

    what is this meaning that these are being AND with one another .??
    can i write all the configuration bit in a single line with the bits that AND with one another.
    please Explain it


    Regards,
     
  2. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi ect,
    Look at this PDF list of CONFIG options, select 18F452.
    E
     
  3. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    my question was something different :p
     
  4. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    I don't think they are logically and in that context.
    They might be in two lines because the bits are parts of two config bytes/words.

    Are you using a BASIC or C compiler?
    The midrange pic config in asm might look something like:
    Code (Text):
    1.  
    2. DEVICE LVP_OFF,BOD_OFF,HS_OSC
    3.  
     
    Last edited: Oct 15, 2014
  5. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    The configuration bits are "off" or "unprogrammed" when they are in the '1' state. If you look at the definition of the constants you'll see that they are all '1's except for a single '0' bit. When these constants are bitwise ANDed together, the desired '0' bits show up in the resulting constant that is programmed into the configuration word(s).
     
    ect_09 and djsfantasi like this.
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Believe it or not we have no idea your skill set, just possibly a guess. Nor do we remember what tools you use, such as the compiler and other such things you are asking question about.

    One can AND together several constants to set multiple or individual bits, or actually reset them. One could use an OR to set bits.

    This device has some 33 config bits in 14 bytes. Do you really expect to set them all in a single line?

    Open up the data sheet for this device and read section 19.1.

    Open up the users guide for your compiler and check the section on config bits.
     
    ect_09 likes this.
  7. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    using HI-Tech compiler
     
  8. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    using Hi-Tech compiler
    and i have a beginner level..
    i know about AND gate for binary.
    for example
    Code (Text):
    1.           0101
    2. AND  0011
    3.  ans      = 0001
    but am confused about it
    Code (Text):
    1. OSCSDIS & HSPLL
     
  9. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    Look at the definition of the constants in the header file, and pay attention to what I previously posted. Each constant should have one or more zeros corresponding to the bits that must transition from the unprogrammed state ('1') to the programmed state ('0'). Do I have to post in capitals with bold and underlining -- sheeesh!!
     
Loading...