• 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.

Need help in pic 16f877 interrupt

Status
Not open for further replies.

humblelearner

New Member
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.:eek:

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:

arunb

Member
a delay inside an ISR may not be a good idea, set a flag instead, then execute the delay in the main loop...
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top