+ Reply to Thread
Results 1 to 2 of 2

Thread: Need help in pic 16f877 interrupt

  1. #1
    humblelearner Newbie
    Join Date
    Dec 2008
    Posts
    4

    Need help in pic 16f877 interrupt

    I decided to have a try on using the interrupt function in pic16f877 but i wonder is there some mistakes on my program. The interrupt is not running no matter how many times i press the interrupt button. This problem really drives me mad. Just to give myself an introduction to interrupt function, I just wanna use a push button (which connect to the rb0/inte pin of portb) to interrupt the main program (which is 8 leds in portc that toggle continuously). During the interrupt subroutine, I intend to let all the 8 leds in portc to on for 5 seconds. Hereby is my program written in mikroC.

    Any help would be greatly appreciated.

    void interrupt() {
    PORTC = 0x11; // To switch on all the LED of PORTC
    Delay_ms(5000); // for 5 second
    INTCON.INTF = 0; //clear the interrupt flag
    }

    void main() {

    INTCON = 0b10010000; // Enable GIE and INTE
    PORTC = 0; // Initialize PORTC
    TRISC = 0; // Configure PORTC as output

    while(1) {
    PORTC = ~PORTC; //toggle PORTC for 0.5 second by waiting for
    Delay_ms(500); //interrupt
    }
    }
    Last edited by humblelearner; 10th July 2009 at 07:38 AM.


  2. #2
    arunb Newbie
    Join Date
    Oct 2006
    Posts
    170

    a delay inside an ISR may not be a good idea, set a flag instead, then execute the delay in the main loop...

+ Reply to Thread

Similar Threads

  1. PIC 16F877 external Interrupt Problem!!!
    By mesamune80 in forum Micro Controllers
    Replies: 6
    Latest: 24th June 2008, 02:18 AM
  2. Replies: 11
    Latest: 31st May 2008, 04:40 PM
  3. URGENT!! 16F877 & USART & Interrupt & Recieve Problem
    By DaMieN in forum Micro Controllers
    Replies: 0
    Latest: 18th September 2007, 11:53 AM
  4. 16F877 Timer0 Interrupt Affecting ADC
    By sebana in forum Micro Controllers
    Replies: 13
    Latest: 12th September 2007, 10:43 AM
  5. External Interrupt not working - 16F877
    By usaf1 in forum Micro Controllers
    Replies: 0
    Latest: 15th September 2003, 01:17 AM

Tags for this Thread