Continue to Site

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.

  • 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.

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?
 
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
 
datasheet page 82 said:
8.4 INT Pin
The INT pin can be used to generate an asynchronous
edge-triggered interrupt. This interrupt is enabled by
setting the INTE bit of the INTCON register. The
INTEDG bit of the OPTION register determines on which
edge the interrupt will occur. When the INTEDG bit is
set, the rising edge will cause the interrupt. When the
INTEDG bit is clear, the falling edge will cause the
interrupt. The INTF bit of the INTCON register will be set
when a valid edge appears on the INT pin. If the GIE and
INTE bits are also set, the processor will redirect
program execution to the interrupt vecto
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top