Keil Logo

User Functions

User functions are functions you create to use with the µVision3 debugger. You may enter user functions directly in the function editor or you may use the INCLUDE command to load a file that contains one or more user functions.


  • µVision3 provides a number of system variables you may use in user functions. Refer to System Variables for more information.

User functions begin with FUNC keyword and are defined as follows:

FUNC return_type fname (parameter_list) {
return_type is the type of the value returned by the function and may be: bit, char, float, int, long, uchar, uint, ulong, void. You may use void if the function does not return a value. If no return type is specified the type int is assumed.
fname is the name of the function.
parameter_list is the list of arguments that are passed to the function. Each argument must have a type and a name. If no arguments are passed to the function, use void for the parameter_list. Multiple arguments are separated by commas.
statements are instructions the function carries out.
{ is the open brace. The function definition is complete when the number of open braces is balanced with the number of the closing braces (}).


The following user function displays the contents of several CPU registers. For more information refer to Creating Functions.

FUNC void MyRegs (void) {
  printf ("---------- MyRegs() ----------\n");
  printf (" R4 R8 R9 R10 R11 R12\n");
  printf (" %04X %04X %04X %04X %04X %04X\n",
            R4,  R8,  R9,  R10, R11, R12);
  printf ("------------------------------\n");

To invoke this function, type the following in the command window.


When invoked, the MyRegs function displays the contents of the registers and appears similar to the following:

---------- MyRegs() ----------
 R4   R8   R9   R10  R11  R12
 B02C 8000 0001 0000 0000 0000

You may define a toolbox button to invoke the user function with:

DEFINE BUTTON "My Registers", "MyRegs()"


  • µVision3 checks that the return value of a user function corresponds to the function return type. Functions with a void return type must not return a value. Functions with a non-void return type must return a value. Note that µVision3 does not check each return path for a valid return value.
  • User functions may not invoke signal functions or the twatch function.
  • The value of a local object is undefined until a value is assigned to it.
  • Remove user functions using the KILL FUNC command.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

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.