1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

why do we initialize option register in PIC?

Discussion in 'Homework Help' started by poojapatel2210, Dec 1, 2015.

  1. poojapatel2210

    poojapatel2210 New Member

    Joined:
    Nov 5, 2015
    Messages:
    25
    Likes:
    0
    what happen when i initialize the option register ? why to initialize it
    I want to initialize option register with '11000111'. what is the use of it?
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,141
    Likes:
    907
    Location:
    Rochdale UK
    Read the datasheet.... This register holds prescale / WDT and other flags... The flags are dependent of pic chip used..
     
  3. poojapatel2210

    poojapatel2210 New Member

    Joined:
    Nov 5, 2015
    Messages:
    25
    Likes:
    0
    its 12 F1822 and i did but i want to know .... it says that rising edge is used for external interrupt then y it is used here what is the use of it .

    This instruction moves the data of w register into OPTION_REG (option register) (refer pg.171, 19-1).so now option register has value C7 in it
    OPTION_REG = 11000111


    bit 2-0 PS<2:0>: Prescaler Rate Select bits

    111 = 1 : 256


    bit 3 PSA: Prescaler Assignment bit

    0 = Prescaler is assigned to the Timer0 module

    (A prescaler slows down the TIMER0 down by reducing the clock signal rate to TIMER0. So, to get longer delay we can use prescaler)


    bit 4 TMR0SE: Timer0 Source Edge Select bit

    0 = Increment on low-to-high transition on RA2/T0CKI pin


    bit 5 TMR0CS: Timer0 Clock Source Select bit

    0 = Internal instruction cycle clock (FOSC/4)


    bit 6 INTEDG: Interrupt Edge Select bit

    1 = Interrupt on rising edge of RA2/INT pin


    bit 7 WPUEN: Weak Pull-up Enable bit

    1 = All weak pull-ups are disabled (except MCLR, if it is enabled)
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. poojapatel2210

    poojapatel2210 New Member

    Joined:
    Nov 5, 2015
    Messages:
    25
    Likes:
    0

    initialisation :
    clrwdt
    bcf INTCON,GIE
    how about these two instruction what does it actually do in my initialisation step. I am figuring out code for automatic (touchfree) tap(faucet) using PIC to set valve on and off
     
  6. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,445
    Likes:
    187
    Location:
    Lancashire UK
    clrwdt This clears tha watchdog timer timeout bit. Bit 4 in the status register (Register 3 with any bank selected.)

    bcf INTCON,GIE This cleards the global interrupt enable bit (bit 7 ) in the interrupt control register. (Register 0xB with any bank selected.)

    Les.
     
  7. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,885
    Likes:
    500
    Location:
    Cleveland, OH, USA
    ONLINE
    If you go to page 27 of the datasheet (Table 3-8) you will find what the default value is for every special function register on reset. That will help you know which ones you need to set in code.

    You also need to know that the registers in General Purpose and Common Ram come up in an unknown state after reset. Thus, you need to initialize the resisters you use in that memory area too. That initialization is often just a matter of clearing them, unless their initial state doesn't make any difference to the program.

    John
     
    • Thanks Thanks x 1
  8. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,141
    Likes:
    907
    Location:
    Rochdale UK
     
    • Thanks Thanks x 1

Share This Page