We were using polling technique before in which we were waiting for some event to happen, so in that way we were consuming a lot of CPU time by keeping CPU. But in Interrupt method we can do other work and when interrupt happens we may serve that interrupt according to it’s need or importance.
PIC Microcontroller has following types of Interrupt-
- Timer Interrupt
- Serial Interrupt
- External Interrupt
- Port B Interrupt
In all these Interrupts you 1st need to check if an interrupt occurred, then you need to check which type of Interrupt occurred and you need to write Interrupt Subroutine
The following steps are same in this type of Interrupt–
- Assign Interrupt to that location where it has Highest Priority(0×08) and when interrupt occurs Program Counter should jump to that location(0×08)
#pragma code in=0×08
in()
{
_asm
GOTO chk
_endasm
}
#pragma code - Check which type of Interrupt Occurred and Jump to that Interrupt Subroutine
#pragma interrupt chk
void chk()
{
if(INTCONbits.TMR0IF==1)
T0();
if(PIR1bits.TMR1IF==1)
T1();
}
- You can download Interrupt files from here…. ENJOY……
Incoming search terms:
- interrupts in pic microcontroller (1)
- pic interrupts using c (1)
- pic16f877a serial interrupts (1)
- pic18f4550 port b interrupts (1)
Related posts:
Tutorial 0.0–PIC(18F) Microcontroller Programming in C (I/O Interfacing) PIC Microcontroller C Files Tutorial 0.1–PIC(18F) Microcontroller Programming in C (I/O Interfacing) How To Program PIC(18F) Microcontroller In C Using MPLAB IDE How To Program PIC(16F,10F series) Microcontroller In C Using MPLAB IDE