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.
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
}
}
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: