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
Erik, I think you should let people get a bit of rope if they want to. If they want to hang themselves, it's their choice. If they are really good with ropes, maybe they manage some nice knots instead :)
Yes, there are limitations to jumping to the reset vector. Some startup code survives it, some doesn't. It will not reset any locked-up hardware, but with a bit of luck, the application will behave as after a reset.
In this case, I think it is enough to warn people about the problems, and let them be big boys and decide if they can live with the remaining problems.
The watchdog method only works if you have a watchdog. And in some situations you may have one but not be able to use it. If you for example power your processor from the phone line, the extra power consumption from the watchdog may be the difference between a working and a non-working solution.