PC and interrupts - Page 1
Forum section: electronics / general

author: farsi
author_rank: Regular Contributor
timestamp: October 13, 2016, 05:16:02 pm
content: how does an interrupt affect the PC register in ARM or MIPS ?there are a lot talks on interrupts on the recent embedded linux conference but it still a bit confusing topic to me (see slides on interrupt talks herehttp://events.linuxfoundation.org/events/embedded-linux-conference-europe/program/slides)what should I read to read to understand this better?

author: danadak
author_rank: Super Contributor
timestamp: October 14, 2016, 01:10:28 am
content: There is a lot of material on this, just google "arm interrupt operation"Regards, Dana.

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: October 14, 2016, 01:33:56 am
content: A simple explanation is that an interrupt causes the processor to save the current value of the PC register somewhere (usually on a stack or in a register (EPC on MIPS processors)) and then to reload the PC with an address taken from an interrupt vector table, effectively causing the processor to start executing code at a new address.In the case of an ARM processor, where the processor jumps to depends on the specific processor. ARM Cortex series processors, for example, do it differently from other ARM processors.

author: farsi
author_rank: Regular Contributor
timestamp: October 14, 2016, 11:44:06 am
content: thanks for the pointers. so, from reading, the an interrupt request causes "context switching" (kind of register backup on stack and loading the address of the interrupt service handler). The interrupt service handler runs some code and it goes back to the previous context?

author: langwadt
author_rank: Super Contributor
timestamp: October 14, 2016, 12:04:50 pm
content: Quote from: farsi on October 14, 2016, 11:44:06 amyes that is how interrupts on "all" cpus work, the differences are in how much is done automaticallysome like the arm7 stored only return address and status, and software had to figure out how to store and restore context andwhat ISR to callCortex knows what ISR to call from a table at a predefined address and does all the context store and restore automatically

author: C
author_rank: Super Contributor
timestamp: October 14, 2016, 12:16:45 pm
content: At High level you might think of a function call with no passed data or return data. Never called from your program but could happen at anytime.

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: October 14, 2016, 03:11:51 pm
content: Quote from: farsi on October 14, 2016, 11:44:06 amYes, you can consider an interrupt as causing a "context switch", but be careful here as there are other definitions of context switch. The most common one is what happens when an operating system switches from one task or process to another. Like an interrupt, the OS needs to save the register context of the old task and restore the register context of the new task.

author: langwadt
author_rank: Super Contributor
timestamp: October 15, 2016, 08:13:45 pm
content: Quote from: Sal Ammoniac on October 14, 2016, 03:11:51 pmbasically does the same thing, the simplest of multitasking OS is just a timer interrupt and an array of contexts and instead of returning to where the interrupt occurred, return to the next context in the array