Interrupt

Status
Not open for further replies.

pysdex

New Member
I am using MikroC Pro compiler. I wanted to make the LED blink by pushing a button once and if I push the button the second time once the LED will stop blinking. I can make the LED blink by button push by using interrupt but I cannot make it stop by the button push. Can help me on this problem??? Thanks....
 
void interrupt()
{
portc=~portc;
delay_ms(200);
}

void main()
{
trisc=0;
trisb=0xff;
portc=0;
INTCON.GIE=1;
INTCON.PEIE=1;
INTCON.RBIE=1;
INTCON.RBIF=0;
}

I can make the LED to blink when I push the button but it won't go back to main when I press again. LED will not off when I press second time.
 
I have no idea about PIC programming at all , but yet i cannot see any code that disables the blinking here. You have only written code to make it blink.
Is the code for stopping that blinking hidden in these line?
INTCON.GIE=1;
INTCON.PEIE=1;
INTCON.RBIE=1;
INTCON.RBIF=0;
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…