When an error is detected, an error code is recorded in a circularly accessed global error buffer (errorbuf), and the red LED (Port D, Pin 14) is lit to indicate the error condition to the user. Users may then use a debugger to investigate error buffer to learn the cause of the most recent sequence of errors.
An error message is also written to the output serial port for the first error thrown.
- When debugging, examine errorbuf to learn the most recent sequence of errors.
- errorbuf[] is of length ERRORBUFLEN, and is written to circularly, so that when the buffer is filled, errors continue to be written by restarting at the start of the array.
- The global erroridx gives the index into errorbuf at which the next error will be stored. The most recent error is stored at index erroridx - 1.
- An error is "thrown" by calling
...
flagerror(error_code);
where error_code is an integer value to be stored in the errorbuf array
- Predefined error codes are provided in err486.h for SAMPLE_OVERRUN, MEMORY_ALLOCATION_ERROR, DAC_CONFIG_ERROR, ADC_CONFIG_ERROR, SETBLOCKSIZE_ERROR
- flagerror(error_code) also displays the error code on the LCD, and writes an error message using printf()