Index: firmware/source/sys_selftest.c =================================================================== diff -u -r8c9511a4eb046091fbfe6a3e481eb83c756b288f -r6c1d6a3eaf065c2b2d537d9fef793d73ea328359 --- firmware/source/sys_selftest.c (.../sys_selftest.c) (revision 8c9511a4eb046091fbfe6a3e481eb83c756b288f) +++ firmware/source/sys_selftest.c (.../sys_selftest.c) (revision 6c1d6a3eaf065c2b2d537d9fef793d73ea328359) @@ -43,16 +43,18 @@ /* USER CODE BEGIN (0) */ -/* USER CODE END */ - #include "Common.h" #include "HDDefs.h" #include "SystemCommMessages.h" + +#define LR_OFFSET_WORD_IN_STACK 22 ///< Offset of the link register from the STACK_MARKER +#define STACK_MARKER 0xCAFECAFE ///< Location in the stack to determine the offset in word from the Link Register +#define LR_OFFSET_ADJUSTMENT 4 ///< Adjust the content of the LR so that the Memory Access Violation does not get call continously +/* USER CODE END */ #include "sys_selftest.h" #include "sys_core.h" #include "sys_pmu.h" - /** @fn void selftestFailNotification(uint32 flag) * @brief Self test fail service routine * @@ -1124,11 +1126,10 @@ */ /* USER CODE BEGIN (42) */ uint32_t marker = STACK_MARKER; - uint32_t contentOfLinkRegister = *(volatile uint32_t*)(&marker + LR_OFFSET_WORD_IN_STACK); - *(volatile uint32_t*)(&marker + LR_OFFSET_WORD_IN_STACK) = contentOfLinkRegister + LR_OFFSET_ADJUSTMENT; + uint32_t contentOfLinkRegister = *(volatile uint32_t*)( &marker + LR_OFFSET_WORD_IN_STACK ); + *(volatile uint32_t*)( &marker + LR_OFFSET_WORD_IN_STACK ) = contentOfLinkRegister + LR_OFFSET_ADJUSTMENT; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, (U32)SW_FAULT_ID_ILLEGAL_MEM_ACCESS, contentOfLinkRegister ) // log LR to determine what caused violation /* USER CODE END */ - } /** @fn void stcSelfCheckFail(void)