CAN Message RAM API Functions¶
The code for this module is contained in source/stl_can_ram.c
with include/stl_can_ram.h containing the API declarations
for use by applications.
Error Injection¶
To inject errors to be detected with the STL_CAN_RAM_testRAM() and STL_CAN_RAM_checkErrorStatus() functions, call STL_CAN_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 parity.
Module Details¶
-
group
stl_can_ram Defines
-
STL_CAN_RAM_PASS0U¶
-
STL_CAN_RAM_ERROR1U¶
-
STL_CAN_RAM_ADDR_OFFSET0x1000U¶
-
STL_CAN_RAM_MAX_ADDR_OFFSET0x13F1U¶
-
STL_CAN_RAM_PARITY_OFF(5U << CAN_CTL_PMD_S)¶
-
STL_CAN_RAM_NO_COPY0xFFFFFFFFU¶ Value to indicate to STL_CAN_RAM_testRAM() through the copyAddress parameter that the test should run a destructive test on the region of CAN message RAM without saving and restoring its contents.
Functions
-
void
STL_CAN_RAM_testRAM(const uint32_t canBase, 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 CAN message RAM objects.
This function performs a March13N memory test on the range of CAN message RAM objects specified by
canBase, 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_CAN_RAM_NO_COPY for the copyAddress and a destructive test will be performed instead.- Parameters
canBase: is the base address of the CAN controller.pattern: is the test pattern to use.startAddress: is the starting address (inclusive) of the CAN message RAM range to test.endAddress: is the end address (inclusive) of the CAN 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_CAN_RAM_NO_COPY.
The test patterns and the March13N memory test algorithm provided test the memory for stuck-at-faults. The parity bits will show if any were detected. Use STL_CAN_RAM_checkErrorStatus() to read the parity status.
- Note
Note to take care calculating the size of memory needed for copyAddress. The March13N function is not specific to the CAN 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_CAN_RAM_injectError(const uint32_t canBase, const uint32_t address, const uint32_t xorMask)¶ Injects an error into a CAN 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 or parity bits.- Parameters
canBase: is the base address of the CAN controller.address: is the address of the word in the message RAM where the error will be injected.xorMask: mask of the bit to flip in address.
- Return
None.
-
uint16_t
STL_CAN_RAM_checkErrorStatus(const uint32_t canBase)¶ Returns the status of the CAN message RAM parity error detected bit.
This function checks if any parity errors have been detected by the CAN message RAM parity logic.
- Parameters
canBase: is the base address of the CAN controller.
- Return
If the CAN error status register indicates a parity error the function returns STL_CAN_RAM_ERROR. Otherwise, the function returns STL_CAN_RAM_PASS.
- Note
Several bits in the CAN error status register (CAN_ES) are cleared on a CPU read of the register which this function performs. If the potential clearing of these bits (see device Technical Reference Manual for details) is undesired behavior for your application, use different means of reading the status.
-