C166: PERFORMING A SOFTWARE RESET IN C
Information in this article applies to:
I need to perform a software reset in C without using inline
assembly. How can I do that?
There are 2 ways to accomplish this depending on what you want to
The following reset function jumps to 0 and starts executing
code from there. Note that since this is only jumping to the reset
vector, the chip is not actually being reset. The startup code
(executed before EINIT) will have no effect.
void reset (void)
((void (far *) (void)) 0x000000) ();
The following code is generated for the reset function. The
?C_SCALLI routine calls the address stored in R4 and R5 (which is
0000 E004 MOV R4,#00H
0002 E005 MOV R5,#00H
0004 DA000000 E CALLS SEG (?C_SCALLI),?C_SCALLI
0008 CB00 RET
The Keil compiler supports a number of "intrinsic library
functions". These are not really functions. When you use one of
them, the compiler inserts a C16x architecture specific instruction
inline. You do not need to use the "asm" pragma and you don't need
to insert assembly mnemonics yourself.
To perform a software reset, use intrinsic library function
_trap_ with a parameter of 0. For example:
If you look at the listing file, you will see that main
function has an SRST assembly instruction in place of
Refer to _trap_
in the C166 User's Guide.
Last Reviewed: Friday, July 15, 2005