4.1.2.1 DIAG_CPU_RegisterResetStateCheck()
void DIAG_CPU_RegisterResetStateCheck (void )
Validates the reset state for all CPU control and status registers.
It detects incorrect reset or default states of individual bits or registers. If the Reset state of any register is incorrect, the function re-initializes the register with the correct default value. The return value is a PASS/FAIL result .CPU registers considered for RESET state check are:
-
STATUS
-
WREG
-
FSR0H
-
FSR0L
-
FSR1H
-
FSR1L
-
INTCON
Some user-requirements and limitations of this diagnostic API are listed below:
(a) This diagnostic must be executed prior to any other diagnostic on start-up, to avoid incorrect operation of other diagnostics or application initialization code, due to unexpected initial register values. (b) Interrupts need to be disabled before executing this diagnostic function. (c) Some registers (PC, PCLATH and STATUS) are not tested in this diagnostic mechanism, because the C run time start-up environment would initialize and modify these registers,thereby making their states unpredictable.Note:
DIAG_CPU_RegisterResetStateCheckGetResult() must be called from main to know the status of CPU Register Reset State Check diagnosis.
Refer to the AoUs listed in Assumption of Use to ensure the correct operation of this function.
| None. |
None. |
MISRA C:2012 Deviation Advisory: misra-c2012-15.5
Justification: This diagnostic test is called by the run-time start-up code, and it stores the test status in cpu_register_reset_state, which is a persistent variable. The diagnostic function needs to return as soon as an error is detected. The function, upon detecting a fault in CPU registers, sets the cpu_register_reset_state to DIAG_FAIL and returns to the caller function, without testing other CPU registers and increasing the start-up delays.