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

Jumping back to main program inside ISR

Hi all,

I have a C51 application that requires the following operation which is close to a reset but it is not a reset:

1. when a bit is set in a register, call a function and return
2. when a bit is cleared in a register, exit the ISR and jump back to the main routine (the stack should be reset).

I use Keil C51 and uses the following method trying to achieve the aims but to no avail:

void isr(void) interrupt
{ if (register & bit) function1(); else
#pragma asm ljmp 800H; // 800h=main routine address
#pragma endasm
}

I tried this routine but it seems that the code is stuck. Has anybody tried a similar implementation, or is there anything that I can do to implement such a scheme?

Thanks very much for your response and Best Regards.

William

Parents
  • Hi,

    I have had to use a technique that might be similar, whereby an ISR was required to trigger a processor reset.

    For this it was necessary to carry out:

    LJMP 0000h
    

    The stack, and most everything else, was reset as a consequence and the main routine was re-entered.

    If this is similar, then you will have to be careful of a number of special actions that are required if the jump to the startup is going to be successful on every attempt - But that would be the next step.

    Ignore Erik's refound silliness!

    Asuming the reason for the requirement is appropriate and justifiable - You, as a programmer of an embedded system, should always be prepared to interpret the rules in a manner that allows the task to be done in a manner that works as the requirement needs.

Reply
  • Hi,

    I have had to use a technique that might be similar, whereby an ISR was required to trigger a processor reset.

    For this it was necessary to carry out:

    LJMP 0000h
    

    The stack, and most everything else, was reset as a consequence and the main routine was re-entered.

    If this is similar, then you will have to be careful of a number of special actions that are required if the jump to the startup is going to be successful on every attempt - But that would be the next step.

    Ignore Erik's refound silliness!

    Asuming the reason for the requirement is appropriate and justifiable - You, as a programmer of an embedded system, should always be prepared to interpret the rules in a manner that allows the task to be done in a manner that works as the requirement needs.

Children