I have a problem with interrupt. I try to stop blink LED connected at port D by using external interrupt (RB0).
My code is shown below. After "Build" I got an error "_interrupt_stop:label not found"
Please help to explain what is wrong?
void interrupt(void)
{
if(intcon.intf == 1){ goto stop;intcon.intf = 0;}
}
void main()
{
anselh.f4=0; //rb0 intrrupt
trisb.f0=1;
intcon=0b10010000;
trisd=0x00;
trisc.f1=1;
portd=0xaa;
while(1);
stop: portd=0xff;
}
problem with interrupt and goto command
Re: problem with interrupt and goto command
Hello,
in one project I have same problem. simple code but not work.
I think that is problem in software (sometimes).
best regards,
ivan
in one project I have same problem. simple code but not work.
I think that is problem in software (sometimes).
best regards,
ivan
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: problem with interrupt and goto command
Hello,
Labels have function scope. So if all you need to do is to declare your statement in the same function where you use goto statement.
Please check Help file for details.
Best regards.
Labels have function scope. So if all you need to do is to declare your statement in the same function where you use goto statement.
Please check Help file for details.
Best regards.
-
- Posts: 3
- Joined: 21 Mar 2012 11:21
Re: problem with interrupt and goto command
Thank you for your suggestion. But I'm not clear. It means I cannot use "goto" command out of the interrupt loop in this case, ain't it.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: problem with interrupt and goto command
Hello,
This was implemented because of limitations that some architectures have.
Also we always recommend our users not to use goto labels since the same can be accomplished without them.
Please try to use exit for breaking from interrupts or just invoke your function.
Best regards.
This was implemented because of limitations that some architectures have.
Also we always recommend our users not to use goto labels since the same can be accomplished without them.
Please try to use exit for breaking from interrupts or just invoke your function.
Best regards.