Author Topic: PC and interrupts  (Read 3284 times)

0 Members and 1 Guest are viewing this topic.

Offline farsiTopic starter

  • Regular Contributor
  • *
  • Posts: 66
PC and interrupts
« on: October 13, 2016, 05:16:02 pm »
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 here http://events.linuxfoundation.org/events/embedded-linux-conference-europe/program/slides )

what should I read to read to understand this better?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: PC and interrupts
« Reply #1 on: October 14, 2016, 01:10:28 am »
There is a lot of material on this, just google "arm interrupt operation"


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1816
  • Country: us
Re: PC and interrupts
« Reply #2 on: October 14, 2016, 01:33:56 am »
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.
"That's not even wrong" -- Wolfgang Pauli
 

Offline farsiTopic starter

  • Regular Contributor
  • *
  • Posts: 66
Re: PC and interrupts
« Reply #3 on: October 14, 2016, 11:44:06 am »
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?
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 5857
  • Country: dk
Re: PC and interrupts
« Reply #4 on: October 14, 2016, 12:04:50 pm »
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?

yes that is how interrupts on "all" cpus work, the differences are in how much is done automatically

some like the arm7 stored only return address and status, and software had to figure out how to store and restore context and
what ISR to call 
 
Cortex knows what ISR to call from a table at a predefined address and  does all the context store and restore automatically 

 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us
Re: PC and interrupts
« Reply #5 on: October 14, 2016, 12:16:45 pm »

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.
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1816
  • Country: us
Re: PC and interrupts
« Reply #6 on: October 14, 2016, 03:11:51 pm »
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?

Yes, 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.
"That's not even wrong" -- Wolfgang Pauli
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 5857
  • Country: dk
Re: PC and interrupts
« Reply #7 on: October 15, 2016, 08:13:45 pm »
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?

Yes, 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.

basically 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


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->