This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrupt servicing after longjmp instruction

I'm using Keil compiler for 8051Warp uP.
I would like to make a jump from an interrupt
routine back to the main function, this way:

main ()
{
init_function();

if (setjmp(env)!=0)
{
// Recovery procedure here
...
}

while (1)
{
// body of my program
...
}

}

void irq (void) interrupt (12)
{
if (condition) longjmp (env,1);
}

void init_function()
{
IE = 0xA0;
IEN1 = 0xC4;
IP = 0x00;
IP1= 0x40;
}

I'm experiencing the following problem.
Right after the longjmp instruction, the execution actually
restarts at the setjmp instruction point (as i wish), but no more interrupt
can be serviced after this jump.
It looks like the IE.7 bit has been reset in some way. Anyway, even if i set
the IE / IE1 registers after the jump, no more interrupt are serviced
by the uP.
Somebody could help me? Thanx.

Parents
  • Pietro, I see gentlemen are discussing something rather different from your initial question. But to solve your problem you can use the following function just after your long jump:

    void dummy(void)
    {
    #pragma asm
    reti
    #pragma endasm
    }

    This function effectively does nothing but it resets interrupt service routine flag (not available directly) and thus reanables your interrupt. Be careful - if you have multiple interrupts EACH of them should be treated in this way. On the other hand, nothing bad will happen if you perform this function excessive number of times, so if you have enough time, you can do it in a loop.
    Regards,
    M.

Reply
  • Pietro, I see gentlemen are discussing something rather different from your initial question. But to solve your problem you can use the following function just after your long jump:

    void dummy(void)
    {
    #pragma asm
    reti
    #pragma endasm
    }

    This function effectively does nothing but it resets interrupt service routine flag (not available directly) and thus reanables your interrupt. Be careful - if you have multiple interrupts EACH of them should be treated in this way. On the other hand, nothing bad will happen if you perform this function excessive number of times, so if you have enough time, you can do it in a loop.
    Regards,
    M.

Children