Menu

Any error in my code I implemented with XC8 compiler?

Kuangtae
2017-10-30
2018-01-21
  • Kuangtae

    Kuangtae - 2017-10-30

    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(Here is its datasheet:http://www.kynix.com/uploadfiles/pdf65976/PIC18F8722-E2fPT_787736.pdf).

    Following is the code:

    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");
    }
    

    Thanks a lot if you could help me!

     

    Last edit: Kuangtae 2017-10-31
  • Anobium

    Anobium - 2017-10-30

    We could help but this is not the Microchip XC8 forum.

    We would simply use Great Cow BASIC and it simple. :-)

     

Log in to post a comment.