CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

INT_RB interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rfjhh



Joined: 31 Mar 2011
Posts: 51
Location: Mexico

View user's profile Send private message

INT_RB interrupt
PostPosted: Fri Apr 15, 2011 11:25 am     Reply with quote

What can I do to make the program leave the interrupt routine, because
once it enters the routine it keeps repeating itself.
Code:

#include<16f876a.h>
#device ADC=10
#use delay (clock=20MHz)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#use fixed_io(c_outputs = PIN_C2, PIN_C6)
#fuses HS, NOWDT, NOBROWNOUT, NOLVP


int conta = 0;
#int_rb
void rb_isr()
{
   printf("Entro a la interrupcion");
   conta = 0;   
}

void main()
{
   set_tris_b(0xf0);
   clear_interrupt(int_rb);
   enable_interrupts(INT_RB);
      enable_interrupts(GLOBAL);
   for(;;)
   {
      while(conta == 0)
      {
         printf("\r\nEsperando entrar a la subrutina......");
         conta++;
      }
   }
}
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 15, 2011 1:24 pm     Reply with quote

some ideas...

1) add 'errors' to the #use RS232(...) function

2) get rid of fast_io() and set_tris() functions. These are best left for experts to use, novices can waste a LOT of time by misusing these functions. Let the compiler do it all for you, automatically, no thinking required!

3) be sure pullups are on all of the PORTB pins.

4) Read how INT_RB works in the compiler onscreen help file and the datasheet.ANY transition will trigger the ISR (fe,te,any pin)

5) be sure to disable any onchip perherial that is muxed onto the PORTB pins...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 15, 2011 1:28 pm     Reply with quote

The reason the interrupt is stuck and repeating forever, is because you
need to clear the "mismatch condition" in the INT_RB circuit inside the
PIC. This is fully described in the PIC data sheet. You can clear the
mismatch condition by reading PortB, or just read the one pin.
Do this with the input() function, inside the interrupt routine.
rfjhh



Joined: 31 Mar 2011
Posts: 51
Location: Mexico

View user's profile Send private message

Thanks
PostPosted: Sun Apr 17, 2011 7:48 pm     Reply with quote

I've already readed the portb and the mismatch condition has been cleared. Thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group