Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC PCLATH and INTERRUPT

Status
Not open for further replies.

ibrar

Member level 2
Joined
Apr 11, 2006
Messages
51
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Location
Lahore, Pakistan
Activity points
1,613
HI all,

I have a question about pic PCLATH.

Lets say i have values in PCL=2Fh and PCLATH=02h then i load a value in PCLATH=08h and after that before calling a routine an interrupt comes my question is that what is the return address from interrupt.

Thanks and regards

iBrAr Ahmad
 

Return address is the current PC when the interrupt comes. The value of the PCLATH doesn't matter. But, you need to save the original PCLATH value at the beginning of the interrupt service routine (ISR), and modify it according to GOTO, CALL addresses used in the ISR. When you are done, restore it just before leaving the ISR.

Failing to modify PCLATH at the beginning of the ISR may cause the CALL and GOTO instructions used in ISR to jump to unpredictable addresses, which generally means catastrophic failure. Failing to restore PCLATH to its original value before returning from ISR may cause the same problem when the first GOTO or CALL instruction is executed after code flow returns from the ISR. Remember, PCLATH is used when a CALL or GOTO instruction is executed, or when the PCL register is modified. It has no effect on RETURN or RETFIE instructions, nor the hardware interrupt jumps to the interrupt vector.
 
  • Like
Reactions: ibrar

    ibrar

    Points: 2
    Helpful Answer Positive Rating
Hello Dear Tagli

Thanks for your kind replay. i am facing the same problem as u mention as my program jumps to an unexpected place. i will follow your instructions and let u know if have any problem
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top