why do we initialize option register in PIC?

Status
Not open for further replies.

poojapatel2210

New Member
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?
 
Read the datasheet.... This register holds prescale / WDT and other flags... The flags are dependent of pic chip used..
 
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) ().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)
 
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
 
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.
 
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
 
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…