Interrupts - mikroElektronika PIC Microcontrollers PIC12 User Manual

Mikroc user's manual
Table of Contents

Advertisement

mikroC - C Compiler for Microchip PIC microcontrollers

Interrupts

Interrupts can be easily handled by means of reserved word interrupt. mikroC
implictly declares function interrupt which cannot be redeclared. Its prototype is:
void interrupt(void);
Write your own definition (function body) to handle interrupts in your application.
mikroC saves the following SFR on stack when entering interrupt and pops them
back upon return:
PIC12 and PIC16 family:
PIC18 family:
Note: mikroC does not support low priority interrupts; for PIC18 family, interrupts
must be of high priority.
Function Calls from Interrupt
You cannot call functions from within interrupt routine, but you can make a
function call from embedded assembly in interrupt. For this to work, the called
function (
1.
func1
2.
func1
The stated rules also apply to all the functions called from within
Note: mikroC linker ignores calls to functions that occur only in interrupt assem-
bler. For linker to recognize these functions, you need to make a call in C code,
outside of interrupt body.
Here is a simple example of handling the interrupts from TMR0 (if no other
interrupts are allowed):
void interrupt() {
counter++;
TMR0 = 96;
INTCON = $20;
} //~
page
34
,
W
STATUS
(fast context is used to save
FSR
in further text) must fulfill the following conditions:
func1
does not use stack (or the stack is saved before call, and restored after),
must use global variables only.
MikroElektronika: Development tools - Books - Compilers
,
,
FSR
PCLATH
,
WREG
STATUS
mikroC
making it simple...
,
)
BSR
.
func1

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents