You are on page 1of 2

//counter

#include<pic.h>
void interrupt ISR()
{
if(RBIF==1)
{
PORTD=PORTB;
}
RBIF=0;
}
main()
{
TRISD=0;
GIE=1;
RBIF=0;
RBIE=1;
TRISB=255;
while(1);
}
bash-3.2$ cat counter.c
#include<pic.h>
#pragma interrupt chk_isr
void chk_isr()
{
if(TMR1IF==1)
TMR1IF=0;
}
#pragma code MYINT=0x08
void MYINT()
{
chk_isr();
}
main()
{
TRISB=0;
PORTB=0;
TRISC=1;
TMR1L=0x00;
T1CON=0x06;
GIE=1;
PEIE=1;
TMR1IE=1;

TMR1ON=1;
TMR1IF=0;
while(1)
{
PORTB=TMR1L;
}
TMR1ON=0;
}
bash-3.2$ cat external.c
#include<pic.h>
void interrupt ISR()
{
if(INTF==1)
{
RD0=~RD0;
}
INTF=0;
}
main()
{

TRISD=0;
RD0=0;
GIE=1;
INTF=0;
INTE=1;
while(1);
}
bash-3.2$ cat timer.c
#include<pic.h>
void interrupt ISR()
{
if(TMR2IF==1)
{
RB1=~RB1;
TMR2=0xCF2C;
TMR2IF=0;
}
}
main()
{
T2CON=0x20;
TRISB=0;
TMR2=0xCF2C;
GIE=1;
PEIE=1;
TMR2IE=1;
TMR2IF=0;
TMR2ON=1;
RB1=1;
while(1);
}

bash-3.2$ exit
exit