Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Question about RB0/INT interrupts

Status
Not open for further replies.

tattee

New Member
When is it useful to use this interrupt? I,ve been having problems using this interrupt ang portb4-7 interrupt. Can I just use all portb4-7 interrupts instead?
 
When is it useful to use this interrupt? I,ve been having problems using this interrupt ang portb4-7 interrupt. Can I just use all portb4-7 interrupts instead?

hi,
I find the PORTB.0 intr useful for determinig time periods.
eg: say you have a external RTC clock divider , say a 4060 which gives a pulse every 0.5 sec.
You could use this precise interval to create a real time clock.

Also if you wanted to measure the period of an incoming signal, use PORTB.0 intr to start/stop an internal counter.

Ref the other PORTB intr, that depends upon your application.:)
 
Last edited:
I was just wodering because at times my code runs perfectly on all interrupts. Other times, everything is a mess. Here is the code:

Code:
#define X            1
#define Y      2
#define Z             3
#define W      4

unsigned short SWITCH = 0;

void Interrupt()
{
  if(INTCON.INTF)
  {
       SWITCH = W ;
       PORTA.F1 = 1;
       INTCON.INTF = 0;
       INTCON.RBIF = 0;
       INTCON.RBIE = 0;
  }
  else if(INTCON.RBIF)
  {
      if(PORTB.F5 == 0)                 
      {
         SWITCH = X;
         INTCON.RBIF = 0;
      }
      else if(PORTB.F6 == 0)             
      {
         SWITCH = Y;
         INTCON.RBIF = 0;
      }
      else if(PORTB.F7 == 0)
      {
         SWITCH = X;
         INTCON.RBIF = 0;
      }
   }
}

void main()
{ 
   init_all();

   do {
        switch(SWITCH)
        {
          case X:
                  INTCON.GIE = 0;
                 //do something here           
                 INTCON = 0b10011000;
          break;

          case Y:
                 INTCON.GIE = 0;
                 //do something here   
                 INTCON = 0b10011000;
          break;

          case Z:
                 INTCON.GIE = 0;
                 //do something here   
                 INTCON = 0b10011000;
          break;
          
          case W:
                 INTCON.GIE = 0;
                 PORTA.F0 = 1;
                 INTCON = 0b10011000;
          break;
          }
     } while(1);

So far, I haven't experienced some strange things when PORTs B5-B7 are interrupted. The weird stuff comes out when RB0/INT is interrupted. Sometimes "case W" keeps on executing and never stops, at other times it works smoothly. Why is this happening?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top