User`s manual

Dynamic C Users Manual digi.com 119
8. RUN-TIME ERRORS
Compiled code generated by Dynamic C calls an exception handling routine for run-time errors. The
exception handler supplied with Dynamic C prints internally defined error messages to a Windows mes-
sage box when run-time errors are detected during a debugging session. When software runs stand-alone
(disconnected from Dynamic C), such a run-time error will cause a watchdog timeout and reset. Run-time
error logging is available for Rabbit-based target systems with battery-backed RAM.
8.1 Run-Time Error Handling
When a run-time error occurs, a call is made to exception(). The run-time error type is passed to
exception(), which then pushes various parameters on the stack, and calls the installed error handler.
The default error handler places information on the stack, disables interrupts, and enters an endless loop by
calling the _xexit function in the BIOS. Dynamic C notices this and halts execution, reporting a run-
time error to the user.
8.1.1 Error Code Ranges
The table below shows the range of error codes used by Dynamic C and the range available for a custom
error handler to use. Table 8-1 is valid prior to Dynamic C version 9.30. Starting with DC 9.30, the file
errmsg.ini located in the root directory of Dynamic C can be edited to add descriptions for user-
defined run-time errors that will be displayed by Dynamic C should the error occur.
For example, if the following entry is made in errmsg.ini:
// My custom errors
800=My own run-time error message
Calling “exit(-800)” in an application or library will cause Dynamic C to report “My own run-time error
message” in a message box.
Please see Section 8.2 for information on replacing the default error handler with a custom one.
Table 8-1. Dynamic C Error Types Ranges (prior to DC 9.30)
Error Type Meaning
0–127 Reserved for user-defined error codes.
128–255 Reserved for use by Dynamic C.