MCAN Message RAM API Functions

The code for this module is contained in source/stl_mcan_ram.c with include/stl_mcan_ram.h containing the API declarations for use by applications.

Error Injection

To inject errors to be detected with the STL_MCAN_RAM_testRAM() and STL_MCAN_RAM_checkErrorStatus() functions, call STL_MCAN_RAM_injectError() with an xorMask value that will cause errors. Note that when running the test in “NO_COPY” mode, any injected errors will be overwritten by the first pattern written to the RAM location since this triggers a recalculation of the ECC.

Module Details

group stl_mcan_ram

Defines

STL_MCAN_RAM_PASS 0U
STL_MCAN_RAM_ERROR 1U
STL_MCAN_RAM_MAX_ADDR_OFFSET 0x43FFU
STL_MCAN_RAM_NO_COPY 0xFFFFFFFFU

Value to indicate to STL_MCAN_RAM_testRAM() through the copyAddress parameter that the test should run a destructive test on the region of MCAN message RAM without saving and restoring its contents.

Functions

void STL_MCAN_RAM_testRAM(const uint32_t mcanBase, const STL_March_Pattern pattern, const uint32_t startAddress, const uint32_t endAddress, const uint32_t copyAddress)

Performs a March13N memory test on the specified range of MCAN message RAM objects.

This function performs a March13N memory test on the range of MCAN message RAM specified by

mcanBase, startAddress and endAddress. The test can save and restore the original contents of the message RAM by passing an address to a back up buffer through the copyAddress parameter. The test will copy the original contents of the memory to copyAddress, perform the memory test, and then copy the original contents back to the memory under test. To skip the save and restore, use a value of STL_MCAN_RAM_NO_COPY for the copyAddress and a destructive test will be performed instead.
Parameters
  • mcanBase: is the base address of the MCAN instance.

  • pattern: is the test pattern to use.

  • startAddress: is the starting address (inclusive) of the MCAN message RAM range to test.

  • endAddress: is the end address (inclusive) of the MCAN message RAM range to test.

  • copyAddress: is the address to copy the original contents of the memory under test. It will be used to restore the original memory at the end of the March13N memory test. If no save and restore is required, use a value of STL_MCAN_RAM_NO_COPY.

The test patterns and the March13N memory test algorithm provided test the memory for stuck-at-faults. The message RAM ECC logic will be used to detect issues. Use STL_MCAN_RAM_checkErrorStatus() to read the ECC status.

Note

Note to take care calculating the size of memory needed for copyAddress. The March13N function is not specific to the MCAN message RAM and does not take the byte addressability of the memory into account. Use a buffer twice the size of the actual message RAM region you are testing.

The STL_March functions called by this test disable global CPU interrupts (DINT) and then re-enable them after the test has completed.

Return

None.

void STL_MCAN_RAM_injectError(const uint32_t mcanBase, const uint32_t address, const uint32_t xorMask)

Injects an error into a MCAN message RAM address.

This function injects an error at a specific memory

address. xorMask specifies which bit to flip in order to corrupt the data.
Parameters
  • mcanBase: is the base address of the MCAN instance.

  • address: is the address of the word in the message RAM where the error will be injected.

  • xorMask: mask of the bit or bits to flip in address.

Return

None.

uint16_t STL_MCAN_RAM_checkErrorStatus(const uint32_t mcanBase, MCAN_ECCErrStatus *errStatus)

Returns the MCAN message RAM ECC error status.

This function checks if any ECC errors have been detected or corrected by the MCAN message RAM ECC logic.

Parameters
  • mcanBase: is the base address of the MCAN instance.

  • errStatus: is a pointer to the structure in which the detailed ECC error status will be returned.

Return

If the MCAN error status register indicates an ECC error the function returns STL_MCAN_RAM_ERROR and errStatus will contain additional details about the type of error. Otherwise, the function returns STL_MCAN_RAM_PASS.