3.1.3.1 DIAG_CPU_SelfTest()

uint8_t DIAG_CPU_SelfTest (diag_cpu_execution_mode_t executionMode)

Software Requirement Reference ID: SW_CPU_SELF_TEST_LIB_01  

Executes CPU self-test subsets.This periodic self-test algorithm is used to verify the functional correctness of all CPU instructions, blocks and features.

It is designed to provide test coverage of overall CPU functionality, which includes:  

  • All available instruction opcodes

  • All addressing modes

  • All bits of every address and data bus structure (in both 0 and 1 bit states)

  • The logical functionality of all control and status bits in CPU registers

  • Tll 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. With DIAG_CPU_SELF_TEST_ALL, all the test subset functions may be executed during a single API call. 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

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

Parameters:
in executionMode

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

Returns:

8-bit Error Mask <- - - - - S3 S2 S1>  

Test bit = 1: Subset execution is successful  

Test bit = 0: Subset execution is failed

This error mask will contain the status of all subset executions. Starting from the Least Significant Byte (LSB), each bit indicates the status of an individual subset.