SPLat Logo

CPU: Runtime error codes

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

CPU: Runtime error codes

The instruction

     SPxPoll1   3,!CPU

will return the last recorded runtime error code in U0. The value will be zero if there has not been a runtime error. If there is a recorded runtime error, then the instruction

     SPxPoll2   2,!CPU

will return the address of the offending instruction in U0 (high byte) and U1 (low byte). You can reconstruct the hexadecimal address by displaying U0 followed by U1 in hexadecimal. This can then be related back to the .LST file generated when you translated the program.

The meanings of the runtime error codes are listed below. Please report to us if you get a code that is not listed.

The controller resets its error code when it is turned off. Hence, if you have a display on your controller you can implement a scheme that allows your users to report back any runtime errors. Runtime errors are errors generated by bugs in your program, so having the ability to capture elusive instances can be very useful.

Example

The following program is intended for an MMi99. It checks for an error at startup. If there is an error it displays it on the LCD then sits there making annoying beeps. If there is no error it proceeds to the main program which is a test of the subroutine nesting depth. That program allows you to generate a runtime error by exceeding the allowable nesting depth (push the lower push button to nest one level down). When an error is generated the SPLat board and program are restarted, but with the error code from the previous incarnation preserved.

;Testing runtime error codes in cpu device

         SPxPoll1       3,!CPU       ;At startup test for error
         PushU          0            ;Get the error code to X
         Push                        ;Duplicate
         GoIfZ          CarryOn      ;g/ no error
HaveError:
         OBLCD_SetCur   0,0
         OBLCD_Text     "Err "
         OBLCD_UDecDispXVW           ;Show error code
         OBLCD_Text     " at '"
         SPxPoll2       2,!CPU       ;Get error address
         PushU          0            ;MS byte
         OBLCD_HexDispX
         PushU          1            ;LS byte
         OBLCD_HexDispX

         OBLCD_SetCur   1,0
         OBLCD_Text     "Please report"
BeepLoop:
         On             8
         Pause          5
         Off            8
         Pause          100
         GoTo           BeepLoop

;This "main" program will nest one level down in the
;subroutine stack each time button 8 is pressed, until it crashes

;Test how deep the subroutine stack can be stacked.
;Displays a count on outputs 0-7

A        IncM           0
CarryOn:
         OBLCD_SetCur   0,0
         OBLCD_Text     "Nested "
         OBLCD_UDecDispMVW 0
         WaitOnK        8
         GoSub          A
         Return                    ;Stops translator complaining

Runtime error codes.

0 There is no runtime error logged.

1 Attempted to run past the end of the program -OR- Attempted to execute an Opcode (instruction) not recognized by this controller.

2 A BRANCH/TARGET went outside the program.

3 Attempt to RETURN when not in a subroutine.

4 TARGET list went off end of program memory.

5 Attempting to INPUT from a non-existent input.

6 Attempting to OUTPUT to a non-existent output.

7 Attempting to access a non-existent data memory.

8 Attempting to access a non-existent timer.

9 GOTO to non-existent location. Please notify SPLat with details of circumstances. Should be totally impossible except Firmware 1.0

10 GOSUBs nested deeper than permitted.

11 BRANCH with offset (X) more than 127.

12 GOSUB to non-existent location. Please notify SPLat with details of circumstances. Should be totally impossible except Firmware 1.0

13 BRANCH goes outside program.

14 The specified analog output is not available

15 The specified analog input is not available

16 Base address specified in a mask I/O instruction is not 0, 8, 16 ... etc.

17 Non-existent command code cc in SPx instruction.

18 Requested U location outside 0-19.

19 Bad RAM (data memory) address: falls outside existing RAM.

20 Illegal command code in SPx instruction.

21 SPx instruction not applicable to this peripheral.

22 SPx peripheral reported bad parameter value.

23 Illegal peripheral address in SPx0 instruction.

24 No response from SPx peripheral

25 Bad SPice pin configuration data

26 Shadow memory instruction attempted to access non-existent memory address.

27 A semaphore instruction attempted to access non-existent RAM.

28 A Suspend or Resume instruction attempted to access non-existent RAM.

29 NVEM command code is invalid

30 NVEM bad page select number

31 NVEM pointer out of bounds.

32 NVEM record number overflow error or greater than 255 when pushed onto stack.

33 NVEM RAM destination is out of bounds.

34 UVtoNV instruction runs off end of U.

35 Attempt to write to NVEM page 0 within 128 bytes of end of program.

36 Offset in U too large during Fix/Float to/from U instructions.

37 RTC option is faulty or not fitted.

38 RTC option is faulty or not fitted.

39 RTC event number is invalid.

40 Quadrature encoder channel invalid.

41 TSP string size 0 or >16

48 MultiTrack task queue already full when trying to schedule a task.

49 MultiTrack task queue empty when trying to run task queue.

50 MultiTrack task queue instruction encountered when task queue not running.

51 Unequal number of GoSubs and Returns in a MultiTrack task.

52 Attempting to execute a RunTasksForever instruction with no tasks in the MultiTrack task queue.

53 MultiTrack task queue empty during RunTasksForever.

54 MultiTrack task executed 256 instructions in a row with no yield.

56 Bad Opcode

65 Xwire: You attempted to set a slave address in the master mode or the address supplied is greater than 253

66 Xwire: Tx data range goes past end of RAM

67 Xwire: Attempting to send more data than allowed with this board

68 Xwire: Rx data range goes past end of RAM

69 Xwire: Attempting to receive more data than allowed with this board

70 Xwire: The configuration table in the master contains more than the allowed number of entries.

71 String communications - Bad destination identifier

72 String communications - Command executed without string somms protocol enabled

73 String communications - Tx buffer full during Tx operation

74 String communications - Count value too big during "PrintFill" and "PrintString" instructions

75 String to RAM - String does not fit into user register area

80 Invalid OBCB channel number