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.

Interrupt in the pic microcontroller

Status
Not open for further replies.

Murugesh_89

Full Member level 5
Full Member level 5
Joined
Nov 23, 2012
Messages
266
Helped
7
Reputation
12
Reaction score
6
Trophy points
1,298
Location
India
Visit site
Activity points
3,267
Hi,
I want to know some info regarding interrupts.

I know that when a interrupt occurs the current instruction is completed, next instruction address is stored in Stack, then the isr will be completed and then program execution continues by retrieving address from stack to pc.

My doubt is almost every calculation involves the use of accumulator. When an interrupt occurs, the isr also uses the accumulator. but when returning to the normal program how this accumulator gets the correct value before it went to isr.

Can anybody give me any tutorial on deeply understanding the interrupts?

Thanks,
Murugesh
 

interrupt service functions would in addition to the Program Counter and status register (results of arithmetic operations such as overflow, negative result, etc) would also save any other registers which may be used in the function. This may be automatic, e.g. in C, or under the programmers control, e.g. in assembly language.
These would then be restored when the function exits.
 

You also need to consider a difference between chips. Some of the newer chips, e.g., enhanced midrange, have automatic context saving. Without that function, you need to save STATUS, W, and PCLATH with code when using Assembly.

Just search the datasheet for whichever chip you are using for "context" . Here is an example from the 16F87x, which doesn't have automatic context saving:

eda1.PNG

John
 

when u are using c lang. for coding then compiler handle most of the task regarding SP and PC so it push acc. and other genral purpose register when interrupt occur and pop it when exit.

but when u r using Assembly lang. that time u have to do those things.
 

If you are using assembly language, look at the MPLAB templates, they show the code for entering and leaving the ISR. "Enhanced instruction set" processors do the context saving and restoring for you. Bear in mind that if you are not using one of the enhanced devices, you need to store the STATUS register as well as W because it holds the bank selection bits. If you do not save it, the ISR may return to the correct address but in the wrong bank!

Brian.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top