|
|||||||||||
Technical Support Support Resources
Product Information |
C51: Software Reset in CInformation in this article applies to:
QUESTIONHow can I put a software reset into my source code? ANSWERYou may typecast the address of the reset vector (0x0000) to a function pointer and call that from C using the following:
For example, the following program continuously resets itself.
You should note that the software reset sequence above does not clear the 8051 interrupt system or reset any 8051 peripherals. When the above code is executed inside an interrupt routine, the 8051 blocks subsequent interrupts. Therefore, this sequence cannot be used in interrupt service routines. The following small assembly function may be called from interrupt routines or from your main program. It works by pushing a return of 0x0000 onto the stack and executing an RETI instruction (to return from interrupt). This clears any interrupt conditions and starts program execution from 0000h.
This works well when register bank 0 is selected. If this routine is called and register bank 0 is not selected, the program may not function as expected. You should add the following instruction to the above routine or to the startup code to select register bank 0.
SEE ALSOLast Reviewed: Thursday, February 25, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.