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.

interrupt on pic16f689

Status
Not open for further replies.

maryem

Member
Hello ,
I'm doing a program on MicroC using push buttons and switches
but the problem with the change interruption on porta doesn'twork,
C:
void interrupt (void){
  unsigned char dummy; 
if ((INTCON.RABIF==1) && (PORTA.F0==1) && (INTCON.RABIE==1) )
{
     

         PORTC.F3 = 1;
           PORTC.F4 = 0;
         dummy = PORTA;     /// <- HERE!!!
         dummy = PORTB;     /// <- AND HERE!!!
         INTCON.RABIF =0 ;
         Delay_ms(500);
         PORTC.F3 = 0;
           PORTC.F4 = 0;
        


  }


                       }

void main() {

ANSEL = ANSELH = 0;                   //all pins I/o are cofigurred as digital
C1ON_bit = C2ON_bit = 0;              //Désactivation de deux comparateurs
INTCON.GIE =1 ;                         // Gener al interrupt enabled
INTCON.RABIE=1 ;
INTCON.RABIF=0 ;
IOCA = 1 ;                            //     PORTA cause an interrupt on lofic state change
IOCB = 1;

TRISA=1;                              // PortA  input
TRISB=0b00010000;                     //RB4 input , others output
TRISC=0b00000111 ;                     //portC RC0,RC1,RC2 input , others output
PORTC.F6=0;
PORTC.F7=0;
PORTC.F4=0;
PORTC.F3=0;                                                          



do {
if (PORTA.F0==1)  {
PORTC.F3=1;
PORTC.F4=0 ;
    }
    else if (PORTA.F1==1)  {
PORTC.F3=0;
PORTC.F4=1 ;
    }



}while (1);
}
 
Last edited by a moderator:
You have set IOCA to 1 and IOCB to 1?? Is this where your inputs are? According to the portb rem statement you are using RB4 as input... That means IOCB should be 0x10 ( ooo1oooo)..

Don't know about porta as you haven't specified..
 
thank you , i will try , the interruption is activated by changing in PORTA(pin 0 and 1 ) and PORTB (pin 4)
 
Status
Not open for further replies.

Latest threads

Back
Top