HWBIST API Functions

The code for this module is contained in source/stl_hwbist.c and source/stl_hwbist_s.asm, with include/stl_hwbist.h containing the API declarations for use by applications.

See the application note Hardware Built-In Self-Test for more information about HWBIST.

Error Injection

To inject errors for STL_HWBIST_runFull(), pass it an errorType value that is not STL_HWBIST_NO_ERROR. To inject an error for a micro-run call STL_HWBIST_injectError() before calling STL_HWBIST_runMicro().

Module Details

group stl_hwbist

Defines

STL_HWBIST_BIST_DONE 0x0001U

The full HWBIST operation is complete. HWBIST has either completed the full number of micro-runs to be meet the selected coverage level or has detected an error.

STL_HWBIST_MACRO_DONE 0x0002U

The micro-run has completed.

STL_HWBIST_NMI 0x0004U

An NMI was generated by the HWBIST controller. This could be caused by an external NMI, a time-out failure, or a detected logic error.

STL_HWBIST_BIST_FAIL 0x0008U

The HWBIST detected an error. This could be caused by a time-out failure or a detected logic error.

STL_HWBIST_INT_COMP_FAIL 0x0010U

HWBIST detected a logic error.

STL_HWBIST_TO_FAIL 0x0020U

HWBIST has experienced a time-out failure.

STL_HWBIST_OVERRUN_FAIL 0x0040U

The HWBIST has run enough micro-runs to meet the configured coverage level but still is not reporting STL_HWBIST_BIST_DONE status as expected.

HWBIST_O_CSTCGCR0 0x0U
HWBIST_O_CSTCGCR1 0x4U
HWBIST_O_CSTCGCR2 0x8U
HWBIST_O_CSTCGCR3 0xCU
HWBIST_O_CSTCGCR4 0x10U
HWBIST_O_CSTCGCR5 0x14U
HWBIST_O_CSTCGCR6 0x18U
HWBIST_O_CSTCGCR7 0x1CU
HWBIST_O_CSTCGCR8 0x20U
HWBIST_O_CSTCPCNT 0x24U
HWBIST_O_CSTCCONFIG 0x28U
HWBIST_O_CSTCSADDR 0x2CU
HWBIST_O_CSTCTEST 0x30U
HWBIST_O_CSTCRET 0x34U
HWBIST_O_CSTCCRD 0x38U
HWBIST_O_CSTGSTAT 0x40U
HWBIST_O_CSTCCPCR 0x48U
HWBIST_O_CSTCCADDR 0x4CU
HWBIST_O_CSTCSEM 0xA0U
HWBIST_CSTCSEM_SEMAPHORE 0x03U
PIEVECTTABLE_O_NMI ((INT_NMI >> 16) * 2U)
STL_HWBIST_MICRO_LIMIT_95 650UL
STL_HWBIST_MICRO_LIMIT_99_RUN1 1700UL
STL_HWBIST_MICRO_LIMIT_99_RUN2 300UL
STL_HWBIST_MICRO_LIMIT_99 (STL_HWBIST_MICRO_LIMIT_99_RUN1

+ \

STL_HWBIST_MICRO_LIMIT_99_RUN2)
STL_HWBIST_REF_STACK __asm(" .ref __stack")
STL_HWBIST_MOV_SP_STACK __asm(" MOV SP, #__stack")
STL_HWBIST_C28OBJ __asm(" C28OBJ")
STL_HWBIST_C28ADDR __asm(" C28ADDR")
STL_HWBIST_C28MAP __asm(" C28MAP")
STL_HWBIST_CLRC_PAGE0 __asm(" CLRC PAGE0")
STL_HWBIST_MOVW_DP_0 __asm(" MOVW DP,#0")
STL_HWBIST_CLRC_OVM __asm(" CLRC OVM")
STL_HWBIST_SPM_0 __asm(" SPM 0")
STL_HWBIST_REF_HANDLE_RESET_FXN __asm(" .ref STL_HWBIST_handleReset")
STL_HWBIST_LCR_HANDLE_RESET_FXN __asm(" LCR STL_HWBIST_handleReset")

Enums

enum STL_HWBIST_Core

Values that must be used for as a parameter to STL_HWBIST_claimSemaphore() in order to claim the semaphore properly for the CPU in use.

Values:

STL_HWBIST_CPU01 = 0x02

CPU01.

STL_HWBIST_CPU02 = 0x01

CPU02.

enum STL_HWBIST_Error

Values that must be used as parameter to STL_HWBIST_injectError() and STL_HWBIST_runFull() in order to specify the type of error to inject before executing HWBIST.

Values:

STL_HWBIST_NO_ERROR = 0x0000

No error.

STL_HWBIST_TIMEOUT = 0x000A

Time-out error.

STL_HWBIST_FINAL_COMPARE = 0x00A0

Final MISR compare error.

STL_HWBIST_NMI_TRAP = 0x0A00

NMI trap error.

STL_HWBIST_LOGIC_FAULT = 0x2000

Logic error.

enum STL_HWBIST_Coverage

Values that must be used as a parameter to STL_HWBIST_init() in order to initialize the HWBIST engine before a micro-run for a specific target coverage. Note that not all devices support multiple coverage levels.

Values:

STL_HWBIST_99_RUN1 = 0x0000

99% coverage, run 1 patterns

STL_HWBIST_99_RUN2 = 0x0002

99% coverage, run 2 patterns

STL_HWBIST_95 = 0x0001

95% coverage

Functions

__interrupt void STL_HWBIST_errorNMIISR(void)
uint16_t STL_HWBIST_runFull(const STL_HWBIST_Error errorType)

Performs a hardware built-in self-test of the CPU under test.

This function initializes the HWBIST engine and then injects the

errorType. It also registers the STL_HWBIST_errorNMIISR() as the NMI vector. It then performs a full hardware built-in self-test achieving 99% coverage. If there is a failure in the HWBIST, then a global error flag will be set and the return value will specify a failure. Additionally, if the coverage is not achieved in the expected micro-runs then the test will fail due to an overrun. Before returning, the function will restore the previous NMI vector. vector.
Parameters
  • errorType: is an enumerated type STL_HWBIST_Error which specifies the type of error to inject before executing a full run of HWBIST test.

This function expects the HWBIST semaphore to be claimed by the CPU attempting to run HWBIST by calling STL_HWBIST_claimSemaphore().

Note

There is a corner case where a spurious CPU Timer 1 or CPU Timer 2 interrupt may be triggered when HWBIST completes. This test contains a workaround which clears the TIE bits of Timer 1 and 2 before starting HWBIST interrupt logging and restores them after HWBIST runs.

Return

If the HWBIST full run test passes with no errors within the expected number of micro-runs, then this function returns the status of the HWBIST and the value will be a bitwise OR of STL_HWBIST_BIST_DONE, and STL_HWBIST_MACRO_DONE. If the test fails, then the status of the HWBIST and the return value of the function will have contain a bitwise OR of some combination of the following values: STL_HWBIST_NMI, STL_HWBIST_BIST_FAIL, STL_HWBIST_INT_COMP_FAIL, STL_HWBIST_TO_FAIL, and STL_HWBIST_OVERRUN_FAIL.

uint16_t STL_HWBIST_runMicro(void)

Performs a micro-run of the hardware built-in self-test of the CPU under test.

This function expects the HWBIST engine to already be initialized with STL_HWBIST_init() before it is called. This function performs a HWBIST micro-run and returns its status. Before returning, the function will also restore the previous NMI vector.

In order to achieve 95% coverage, the user needs to initialize the HWBIST controller for 95% coverage and then execute STL_HWBIST_MICRO_LIMIT_95 micro-runs. The HWBIST will complete in STL_HWBIST_MICRO_LIMIT_95 micro-runs if there are no detected faults.

In order to achieve 99% coverage, the user needs to initialize the HWBIST controller for 99% coverage RUN 1 and then execute STL_HWBIST_MICRO_LIMIT_99_RUN1 micro-runs. The HWBIST will complete in STL_HWBIST_MICRO_LIMIT_99_RUN1 micro-runs if there are no detected faults. The HWBIST should then be reinitialized to 99% coverage RUN 2 and then executed for STL_HWBIST_MICRO_LIMIT_99_RUN2 micro-runs to complete 99% coverage.

This function expects the HWBIST semaphore to be claimed by the CPU attempting to run HWBIST by calling STL_HWBIST_claimSemaphore().

Note

This function performs a HWBIST micro-run and is designed to be used as a periodic self-test or PEST.

There is a corner case where a spurious CPU Timer 1 or CPU Timer 2 interrupt may be triggered when HWBIST completes. This test contains a workaround which clears the TIE bits of Timer 1 and 2 before starting HWBIST interrupt logging and restores them after HWBIST runs.

Return

This function returns the status of the HWBIST after the micro-run executes. If the HWBIST micro-run test passes with no errors, then the value will be either STL_HWBIST_MACRO_DONE or a bitwise OR of STL_HWBIST_BIST_DONE | STL_HWBIST_MACRO_DONE. STL_HWBIST_BIST_DONE should be be set after the expected number of micro-runs have been executed to reach the configured coverage level. If the test fails, then the status of the HWBIST and the return value of the function will have contain a bitwise OR of some combination of the following values: STL_HWBIST_NMI, STL_HWBIST_BIST_FAIL, STL_HWBIST_INT_COMP_FAIL, and STL_HWBIST_TO_FAIL.

void STL_HWBIST_restoreContext(void)

Begins the context restore after a CPU reset after a HWBIST micro-run.

This function should not be called by the user, but must be placed at the beginning of RAMM0, memory address 0x0000. After a HWBIST micro-run completes, the CPU will reset and begin executing instructions from 0x0000. The user is responsible for placing this function at memory address 0x0000. This can be done using the linker command file and program sections.

Return

None.

void STL_HWBIST_init(const STL_HWBIST_Coverage coverage)

Initializes the HWBIST engine for operation.

This function initializes the HWBIST engine for the specified level of coverage. This function is intended to be used with

STL_HWBIST_runMicro(). This function should be called once to initialize the HWBIST and not called again until the HWBIST is done which is indicated by a return value of STL_HWBIST_BIST_DONE as this function resets the HWBIST engine.
Parameters
  • coverage: is an enumerated type STL_HWBIST_Coverage which specifies the coverage to achieve.

Return

None.

static void STL_HWBIST_injectError(const STL_HWBIST_Error errorType)

Injects an error into the HWBIST engine for operation.

This function injects an error into the HWBIST using the HWBIST registers.

Parameters
  • errorType: is an enumerated type STL_HWBIST_Error which specifies the error to inject.

Note

This function should be called after STL_HWBIST_init() because STL_HWBIST_init() resets the HWBIST engine and initializes the test.

Return

None.

static bool STL_HWBIST_claimSemaphore(const STL_HWBIST_Core core)

Attempts to claim the HWBIST semaphore for the specified core.

This function attempts to claim the semaphore for the specified core.

Parameters
  • core: is an enumerated type STL_HWBIST_Core which specifies the core attempting to claim the HWBIST semaphore.

Note

This function should be called before STL_HWBIST_init(), STL_HWBIST_runMicro() and STL_HWBIST_runFull().

Return

If the semaphore was claimed successfully, then true is returned. If the semaphore was unable to be claimed, then false is returned.

static void STL_HWBIST_releaseSemaphore(void)

Releases the HWBIST semaphore.

This function releases the semaphore.

Return

None.