Hello ,
I'm doing a program on MicroC using push buttons and switches
but the problem with the change interruption on porta doesn'twork,
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: