mm_pk1
Newbie level 6
- Joined
- Jan 9, 2009
- Messages
- 12
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,372
Dear all,
I am new on PIC12x. Code continuously toggles the GP0 of 12F683 and whenever interrupt (INT) is invoked, GP1 toggles. The problem is that interrupt is invoked only once, and it seems that after executing the ISR, control does not return back to the main function. When interrupt is invoked first time, GP1 toggles but after that LED blinking on GP0 stops. Following is the code and Proteus schematic is also attached for reference please:
I am new on PIC12x. Code continuously toggles the GP0 of 12F683 and whenever interrupt (INT) is invoked, GP1 toggles. The problem is that interrupt is invoked only once, and it seems that after executing the ISR, control does not return back to the main function. When interrupt is invoked first time, GP1 toggles but after that LED blinking on GP0 stops. Following is the code and Proteus schematic is also attached for reference please:
Code:
unsigned char a=0;
void interrupt ()
{
GPIO.F1 = ~a; //Toggle GP1 at each interrupt occurrence
INTCON.F0 = 0; //Clear INT flag
}
void main()
{
ANSEL = 0;
CMCON0 = 7;
TRISIO.F0 = 0; //Continuous blinking LED on this port
TRISIO.F1 = 0; //This port toggles whenever interrupt occurs
TRISIO.F2 = 1; //Making GP2 as input for interrupt
while(1)
{
INTCON = 0xD0; //Enable Global interrupt and INT
{
GPIO.F0 = 0;
Delay_ms(100);
GPIO.F1 = 1;
Delay_ms(100);
}
}
}