h.sharma
Junior Member level 3
I am working on interfacing of tsop 1738 remote control receiver with pic16f877a
here is code using interrupts, problem is that when i compile in MPLAb ide this it shows cgpic.exe has stopped working
please tell me what problem is exactly, it is a prob. with code or software?
here is code using interrupts, problem is that when i compile in MPLAb ide this it shows cgpic.exe has stopped working
Code:
#include<htc.h>
#define _XTAL_FREQ 4000000
unsigned char buf,flag;
main()
{
__delay_ms(100);
PORTB=0;
TRISB=1; //set RB0 as i/p and all other portb bits as o/p
GIE=1; //global interrupt enable
INTE=1; //external interrupt enable
INTEDG=0; //interrupt edge selection
while(1)
{
flag=0;
if(buf==1){RB1=~RB1;__delay_ms(100);}
else if(buf==3){RB2=~RB2;__delay_ms(100);}
else if(buf==13){RB3=~RB3;__delay_ms(100);}
else if(buf==12){RB4=~RB4;__delay_ms(100);}
else if(buf==32){RB5=~RB5;__delay_ms(100);}
else if(buf==33){RB6=~RB6;__delay_ms(100);}
else if(buf==4){RB7=~RB7;__delay_ms(100);}
else if(buf==7){RA0=~RA0;__delay_ms(100);}
else if(buf==6){RA1=~RA1;__delay_ms(100);}
else if(buf==9){RA2=~RA2;__delay_ms(100);}
flag=0;
while(flag==0);
}
}
void interrupt external(void) //ISR
{
INTF=0;
if(RB0==0)
{
__delay_us(100) ;
if(RB0==0)
{
__delay_us(100);
if(RB0==0)
{
__delay_us(889);
if(RB0==1)
{
__delay_us(889);
if(RB0==0)
{
__delay_ms(10.632);
buf=0;
for(int a=0;a<6;a++)
{
buf<<=1;
if(RB0==1)
{
buf++;
}
__delay_ms(1.778);
}
buf&=0b00111111; //filtering the 6 command bits
flag=1;
RA3=1;__delay_ms(30);RA3=0; //indicator LED
}
}
}
}
}
}
please tell me what problem is exactly, it is a prob. with code or software?