DIAG_CPU_SelfTest

Software Requirement Reference ID : SW_CPU_SELF_TEST_LIB_01.

This diagnostic API executes CPU self-test subsets.

This periodic self-test algorithm is used to verify the functional correctness of all CPU instructions, blocks and features. The self-test algorithm is designed to provide test coverage of overall CPU functionality, which includes:

(a) all available instruction opcodes,

(b) all addressing modes,

(c) all CPU-registers,

(d) all bits of every address and data bus structure (in both '0' and '1' bit states),

(e) the logical functionality of all control and status bits in CPU registers, and

(f) all blocks of the Arithmetic and Logic Unit.

The overall test suite is subdivided into three Test Subset functions (each representing a different subset of CPU functionality), which are executed in a cyclic manner. For example, a different Test Subset function may be called by the application every 2 ms, thereby completing the entire test suite every 6 ms; since each Test Subset generates a unique 16-bit data result, three such test results are generated during the 6 ms window.

Each Test Subset function performs a series of tests, incrementally generating a unique 16-bit result at the end of the function execution.

This self-test API works in two modes indicated by diag_cpu_execution_mode_t Enum. With DIAG_CPU_SELF_TEST_ALL, all the Test Subset functions may be executed during a single API call. And with DIAG_CPU_SELF_TEST_SUBSET_1, DIAG_CPU_SELF_TEST_SUBSET_2 and DIAG_CPU_SELF_TEST_SUBSET_3, only a single Test subset function is executed during a single API call.

Functional items covered by each Test Subset are listed below:

1) Subset 1:
  • MOV and MOVW instructions are tested
  • Addressing modes tested: Immediate, File Register, Register Direct and Indirect (with Pre-Increment, Post-Increment, Pre-Decrement, Post-Decrement, Literal Offset and Register Offset)
  • All bits of the program memory address bus are toggled
  • All bits of the SRAM data memory address bus are toggled
  • All bits of the SRAM data bus are toggled
  • SWAP instruction is tested
  • All bit manipulation, bit test, compare and bit-compare-skip operations are tested
  • CPU registers tested for read/write operations
2) Subset 2:
  • All conditional branch instructions with alternative conditions
  • Program Counter (PC) behavior during above program flow change operations
  • All CALL and RETURN operations
  • NOP instruction
  • All stack operations
3) Subset 3:
  • All arithmetic and logic instructions
  • All data rotate and shift instructions
  • All MUL instruction variants
  • Test of CCP register
  • CPU registers tested for read/write operations

This API also updates the DIAG_CPU_SelfTestErrorMask variable which contains the error status of all subsets together.

uint8_t DIAG_CPU_SelfTest(
    diag_cpu_execution_mode_t executionMode
)

Parameters

[in] executionMode

diag_cpu_execution_mode_t Enum

- indicates the operating mode in which the DIAG_CPU_SelfTest diagnostic API function will be executed

Returns

uint8_t 8-bit Error Mask <- - - - - S3 S2 S1>. Test bit = 1: Subset execution is successful; Test bit = 0: Subset execution is failed.