I did many research but couldn't find out what the problem it is. Actually my code as below. I am trying to implement a code in C with XC8 compiler.
To enable a sentence on the LCD of the board while RB6 button is pressed. I enable INCTONbits.GIE = 1 and INTCONbits.RBIE = 1 and INTCONbits.RBIF = 0.
Inside of interrupt, the displaySentence() function is entered to infinity loop to see result. I checked all answers related with interrupt in here but didn't help my problem. What can be problem for RB7-4 interrupt, I am working on PIC18f8722.
void displaySentence();
void initialize();
void interrupt RBINT_ISR(void){
INTCONbits.GIE = 0;
__delay_ms(10);
while(1){
displaySentence();
}
INTCONbits.RBIF = 0;
INTCONbits.RBIE = 1;
INTCONbits.GIE = 1;
}
void main(void)
{
__delay_ms(15);
__delay_ms(15);
__delay_ms(15);
__delay_ms(15);
InitLCD(); // Initialize LCD in 4bit mode
ClearLCDScreen(); // Clear LCD screen
initialize();
while(1);
}
void initialize(){
TRISB = 0x40;
PORTB = 0x00;
// | GIE/GIEH | PEIE/GIEL | TMR0IE | INT0IE | RBIE | TMR0IF | INT0IF | RBIF
// | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0
INTCONbits.RBIF = 0;
INTCONbits.RBIE = 1;
INTCONbits.GIE = 1;
}
void displaySentence(){
WriteCommandToLCD(0x80);
WriteStringToLCD("Interrupt");
WriteCommandToLCD(0xC0);
WriteStringToLCD("is working");
}
Best Answer
Thanks @brhans for your answer I did as you said. I disabled
INTCON2bits.RBPU = 0
and it worked for me.