![]() | ![]() | ![]() |
| |||||||
| General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion? |
![]() |
| | Tools |
| | #1 |
|
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 |
|
a delay inside an ISR may not be a good idea, set a flag instead, then execute the delay in the main loop...
| |
| |
|
| Tags |
| interrupt, pic |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| PIC 16F877 external Interrupt Problem!!! | mesamune80 | Micro Controllers | 6 | 24th June 2008 02:18 AM |
| HIGH and LOW priority interrupt in 16f877 PIC using C programming | cgsumesh77 | Micro Controllers | 11 | 31st May 2008 04:40 PM |
| URGENT!! 16F877 & USART & Interrupt & Recieve Problem | DaMieN | Micro Controllers | 0 | 18th September 2007 11:53 AM |
| 16F877 Timer0 Interrupt Affecting ADC | sebana | Micro Controllers | 13 | 12th September 2007 10:43 AM |
| External Interrupt not working - 16F877 | usaf1 | Micro Controllers | 0 | 15th September 2003 01:17 AM |