4.1.2.1 DIAG_CPU_RegisterResetStateCheck()

void DIAG_CPU_RegisterResetStateCheck (void )

Validates the Reset state for all CPU control and status registers.  

It helps detect incorrect Reset or default states of individual bits or registers. If the Reset state of any register is incorrect, the function reinitializes the register with the correct default value. The return value is a simple PASS/FAIL result.

CPU registers considered for RESET state check are:
  • STATUS

  • WREG

  • FSR0H

  • FSR0L

  • FSR1H

  • FSR1L

  • FSR2L

  • FSR2H

  • PRODL*

  • PRODH*

  • PCLATH

  • PCLATU

  • BSR

  • TABLAT

  • TBLPTRU

  • TBLPTRH

  • TBLPTRL

    These registers are supported only on the PIC18(L)FxxK42 device family. Some user-requirements and limitations of this diagnostic API are listed below:  

    (a) Execute this diagnostic 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) Disable all interrupts before executing this diagnostic function.  

    (c) The PCL, STKPTR, TOSU, TOSH and TOSL registers 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. Furthermore, the PRODH and PRODL registers are not supported for other devices, except the K42 family.  

    Note:

    Call DIAG_CPU_RegisterResetStateCheckGetResult() from main to see the status of CPU Registers Reset State Check diagnosis test.

    Parameters:
    None.
    Returns:

    None.  

    Note:

    Refer to the AoUs listed in Assumption of Use to ensure the correct operation of this function.

    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. Upon detecting a Fault in the CPU registers, it 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.