Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

RB0/INT interrupt not triggered

Status
Not open for further replies.

royalmadhu

Newbie level 3
Joined
Feb 6, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,333
hi
i'm building a pulse counter...
i'm using the external interrupt on RB0 in 16F877A for counting the pulse...
i have also used the TMR0 interrupt in the same interrupt function....

but my variable which is count9 for counting the pulses does not get incremented at all....i'm kind of a newbie when it comes to PICs so can anyone of u friends help me for solving this problem?
I'm simulating the program in proteus...and i'm using a push button to simulate the pulses in that
this is my code...

unsigned int count,count1,count2,count3,count4,count5,count6,count7,count8,count9;



void interrupt()
{
if(INTCON.INTF==1)
{
count9=count9+1;
if(count9==999)
{
count9=0;
}
INTCON.INTF=0;
}


if (INTCON.T0IF==1)
{

...
...//I have plenty of other lines here,,so i'm not puting those here..if u think the rest of the code is needed i'll post that
...
...
..
}

void main()
{
int a,b,c,d,k,m,n;
TRISB=0b01111111;
INTCON= 0b10110000;
OPTION_REG= 0b11000010;
TRISA=0b11111111 ;
ADCON1 = 7;
TRISC=0b00000000;
TRISD=0b00000000;
TRISE=0b111;
count1=count=0;
count7=count6=0;
count8=0;
COUNT9=0;
portc.f2=0;
portc.f0=0;

while(1)
{

...
...
..
}
 

If you debug the code does the interrupt routine ever get triggered?

Is so, do enable the GIE flag when you leave the routine.
 

If you debug the code does the interrupt routine ever get triggered?

Is so, do enable the GIE flag when you leave the routine.

yes i have it jumps to the interrupt routine
 

It might be worth while zipping you code and uploading it, so it can be examined in more detail.
 

It might be worth while zipping you code and uploading it, so it can be examined in more detail.


PHP:
unsigned int count,count1,count2,count3,count4,count5,count6,count7,count8;
 int count9=0;



void interrupt()
{
if(INTCON.INTF==1)
{
  porte.f2=1;
 count9++ ;

if(count9==999)
{

count9=0;
}
INTCON.INTF=0;
}




if (INTCON.T0IF==1)
 {
 /*if(portb.f0==1)
 {
 count9=count9+1;
if(count9==999)
{
count9=0;
}
 } */

 if((portb.f5==1)&&(portb.f3==0))
 {
 count6=count6+1;
 if (count6==100)
 {
 count6=0;
 count7++;
 if (count7==999)
 {
 count7=0;
 }
 }
 }

else if ((portb.f1==1) &&(portb.f4==0))
 {
 count4=0;
 count5=0;
count1=count1+1;

if (count1==300)
{
count1=0;
count=count++;
if (count ==10)
{
count=0;
}
}
}

else if((portb.f4==1)&&(portb.f1==0))
{
count4=0;
count5=0;
count2=count2+1;
if (count2==300)
{
count2=0;
count=count+10;
if(count==100)
{
count=0;
}
}
}
else if((portb.f1==1)&&(portb.f4==1))
{
count4=0;
count5=0;
count3=count3+1;
if (count3==300)
{
count3=0;
count=count+100;
if(count>9999)
{
count=0;
}
}
}

else
{
count4=count4+1;
if(count4==790)
{
count4=0;
count5=count5+1;
if(count5==9999)
{
count5=0;
}
}
}
if(count5>=count)
{
portb.f7=~portb.f7;
count5=0;
count4=0;
}
 if(count9>=count7)
{
porte.f1=1;
}
 else
 {
 porte.f0=0;
 }
}


INTCON.T0IF=0;
  //OPTION_REG.INTEDG=1;

}
void display(int,int,int,int)  ;
void display2(int,int,int);
void main()
{
int a,b,c,d,k,m,n;
 TRISB=0b01111111;
  
INTCON= 0b10110000;  //GIE ,TMR0,TNTE are enabled
OPTION_REG= 0b11000010;  //rising edge ,pullup disabled,prescaler set 
TRISA=0b11111111 ;
ADCON1 = 7;
TRISC=0b00000000;
TRISD=0b00000000;
TRISE=0b000;
count1=count=0;
count7=count6=0;
count4=0;
count8=0;
COUNT9=0;
portc.f2=0;
portc.f0=0;

while(1)
{

  if(portb.f2==1)
{
count4=0;
count5=0;
count2=0;
count1=0;
count=0;
}
if(portb.f6==1)
{
count7=0;
count6=0;
}
a=count5/1000;
b=((count%1000)/100);
c=(((count%1000)%100)/10);
d=((((count%1000)%100)%10)/1);
k=(count7/100);
n=((count7%100)/10 );
m=(((count7%100)%10)/1);
display(a,b,c,d);
display2(k,n,m);
}
}
void display2(int i,int j, int p)
{
if (i==0)
{
portc=0b00000010;
}
if (i==1)
{
portc=0b00010010;
}
if (i==2)
{
portc=0b00100010;
}
if (i==3)
{
portc=0b00110010;
}
if (i==4)
{
portc=0b01000010;
}
if (i==5)
{
portc=0b01010010;
}
if (i==6)
{
portc=0b01100010;
}
if (i==7)
{
portc=0b01110010;
}
if (i==8)
{
portc=0b10000010;
}
if (i==9)
{
portc=0b10010010;
}
if (j==0)
{
portc=0b00000100;
}
if (j==1)
{
portc=0b00010100;
}
if (j==2)
{
portc=0b00100100;
}
if (j==3)
{
portc=0b00110100;
}
if (j==4)
{
portc=0b01000100;
}
if (j==5)
{
portc=0b01010100;
}
if (j==6)
{
portc=0b01100100;
}
if (j==7)
{
portc=0b01110100;
}
if (j==8)
{
portc=0b10000100;
}
if (j==9)
{
portc=0b10010100;
}
if (p==0)
{
portc=0b00001000;
}
if (p==1)
{
portc=0b00011000;
}
if (p==2)
{
portc=0b00101000;
}
if (p==3)
{
portc=0b00111000;
}
if (p==4)
{
portc=0b01001000;
}
if (p==5)
{
portc=0b01011000;
}
if (p==6)
{
portc=0b01101000;
}
if (p==7)
{
portc=0b01111000;
}
if (p==8)
{
portc=0b10001000;
}
if (p==9)
{
portc=0b10011000;
}

}

void display(int x,int y,int z,int w)
{
if (x==0)
{
portd=0b00000001;
}
if (x==1)
{
portd=0b00010001;
}
if (x==2)
{
portd=0b00100001;
}
if (x==3)
{
portd=0b00110001;
}
if (x==4)
{
portd=0b01000001;
}
if (x==5)
{
portd=0b01010001;
}
if (x==6)
{
portd=0b01100001;
}
if (x==7)
{
portd=0b01110001;
}
if (x==8)
{
portd=0b10000001;
}
if (x==9)
{
portd=0b10010001;
}
if (y==0)
{
portd=0b00000010;
}
if (y==1)
{
portd=0b00010010;
}
if (y==2)
{
portd=0b00100010;
}
if (y==3)
{
portd=0b00110010;
}
if (y==4)
{
portd=0b01000010;
}
if (y==5)
{
portd=0b01010010;
}
if (y==6)
{
portd=0b01100010;
}
if (y==7)
{
portd=0b01110010;
}
if (y==8)
{
portd=0b10000010;
}
if (y==9)
{
portd=0b10010010;
}
if (z==0)
{
portd=0b00000100;
}
if (z==1)
{
portd=0b00010100;
}
if (z==2)
{
portd=0b00100100;
}
if (z==3)
{
portd=0b00110100;
}
if (z==4)
{
portd=0b01000100;
}
if (z==5)
{
portd=0b01010100;
}
if (z==6)
{
portd=0b01100100;
}
if (z==7)
{
portd=0b01110100;
}
if (z==8)
{
portd=0b10000100;
}
if (z==9)
{
portd=0b10010100;
}
if (w==0)
{
portd=0b00001000;
}
if (w==1)
{
portd=0b00011000;
}
if (w==2)
{
portd=0b00101000;
}
if (w==3)
{
portd=0b00111000;
}
if (w==4)
{
portd=0b01001000;
}
if (w==5)
{
portd=0b01011000;
}
if (w==6)
{
portd=0b01101000;
}
if (w==7)
{
portd=0b01111000;
}
if (w==8)
{
portd=0b10001000;
}
if (w==9)
{
portd=0b10011000;
}

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top