How to write ISR function for Hardware and software Interrupt

Thread Starter

Allen_Lusy

Joined Dec 10, 2014
12
Till now I used Vendor(Controller Vendor) ISR for handling the Interrupt. But I want to know how to write the ISR. I know about the Vector Table. Will take one simple example for GPIO Interrupt for Port 0. which is having the vector table P0INT_VECTOR(according to datasheet).
  1. Now can any one tell me, how to write a ISR function for this.
I have seen the vendor example,

#pragmavector= P0INT_VECTOR
__interrupt void p0_ISR(void)
{
/*Some statement*/
}
why it is #pragma, and how the function defined as p0_ISR, can we change the function name. What will be the impact of changing the name

I am not used the Software Interrupt much, but I know some basic, it will be used via INT commands.
2.How to write Software ISR.
 

ErnieM

Joined Apr 24, 2011
8,377
We would need to know what compiler and what device you are using to offer any specific advice.

"#pragma" is a C statement used when the core C statements can't handle something (so we do something pragmatic). As far as I know the function name itself is of little importance as normally you never call this function from your other code. C just needs a handle that is not used any where else.
 

Thread Starter

Allen_Lusy

Joined Dec 10, 2014
12
We would need to know what compiler and what device you are using to offer any specific advice.

"#pragma" is a C statement used when the core C statements can't handle something (so we do something pragmatic). As far as I know the function name itself is of little importance as normally you never call this function from your other code. C just needs a handle that is not used any where else.
I am using GNU Compiler and 8051 Controller. Can you please bit Clear, as I am not having Much experience in the controller. I will be thankful if you describe it from Basic point of view.
 

Papabravo

Joined Feb 24, 2006
21,094
In the interrupt service routine
  1. Verify that the interrupt flag gets cleared. In some cases this must be done by an instruction to clear it, sometimes this is automatic.
  2. Re-enable interrupts, if you allow nesting.
  3. Capture data from or output data to the hardware registers.
  4. Return from the interrupt
Resist the urge to do extensive processing in an interrupt routine.
Don't allow any variables to be modified in both the interrupt service routine and the background process.
 
Top