2 Replies Latest reply on Aug 17, 2020 6:22 AM by TeMa_1467596

    how to read cause of reset on PSoC6 (Cy8C6347)

    TeMa_1467596

      I have PSoC Creator 4.2 C code running for both cores in a dual core project for PSoC6 (CY8C6347BZI) and the cm0p core is the master.  As the system boots (or reboots) I need to have code examine the cause of the last reboot.  I have found register RES_CAUSE in TRM (page 581) with definition of bits and what they mean but I'm struggling to come up with the code to read that register.

       

      Any chance of a few lines of example code to read this register so I can take actions based on the cause of the reset?

       

      Thanks,

       

      Ted

        • 1. Re: how to read cause of reset on PSoC6 (Cy8C6347)
          LePo_1062026

          Ted,

           

          Instead of calling RES_CAUSE register directly, use the following call instead:

           

          /*******************************************************************************
          * Function Name: Cy_SysLib_GetResetReason
          ****************************************************************************//**
          *
          * The function returns the cause for the latest reset(s) that occurred in
          * the system. The reset causes include an HFCLK error, system faults, and
          * device reset on a wakeup from Hibernate mode.
          * The return results are consolidated reset causes from reading RES_CAUSE,
          * RES_CAUSE2 and PWR_HIBERNATE token registers.
          *
          * \return The cause of a system reset.
          *
          * | Name                          | Value
          * |-------------------------------|---------------------
          * | CY_SYSLIB_RESET_HWWDT         | 0x00001 (bit0)
          * | CY_SYSLIB_RESET_ACT_FAULT     | 0x00002 (bit1)
          * | CY_SYSLIB_RESET_DPSLP_FAULT   | 0x00004 (bit2)
          * | CY_SYSLIB_RESET_CSV_WCO_LOSS  | 0x00008 (bit3)
          * | CY_SYSLIB_RESET_SOFT          | 0x00010 (bit4)
          * | CY_SYSLIB_RESET_SWWDT0        | 0x00020 (bit5)
          * | CY_SYSLIB_RESET_SWWDT1        | 0x00040 (bit6)
          * | CY_SYSLIB_RESET_SWWDT2        | 0x00080 (bit7)
          * | CY_SYSLIB_RESET_SWWDT3        | 0x00100 (bit8)
          * | CY_SYSLIB_RESET_HFCLK_LOSS    | 0x10000 (bit16)
          * | CY_SYSLIB_RESET_HFCLK_ERR     | 0x20000 (bit17)
          * | CY_SYSLIB_RESET_HIB_WAKEUP    | 0x40000 (bit18)
          *
          * \note CY_SYSLIB_RESET_CSV_WCO_LOSS, CY_SYSLIB_RESET_HFCLK_LOSS and
          *       CY_SYSLIB_RESET_HFCLK_ERR causes of a system reset available only if
          *       WCO CSV present in the device.
          *
          *******************************************************************************/
          uint32_t Cy_SysLib_GetResetReason(void)
          

           

          It takes care of all the messy bits and is controlled by Cypress if changes are needed in the future.

           

          Suggestion:  Perform the Cy_SysLib_GetResetReason() as the first line of text in main().

           

          Len

          2 of 2 people found this helpful
          • 2. Re: how to read cause of reset on PSoC6 (Cy8C6347)
            TeMa_1467596

            Thanks, I added a uint32 and then this line...

             

            rebootCode = Cy_SysLib_GetResetReason();

             

            and it seems to work, a normal startup gives zero and NVIC_SystemReset(); gives 16

             

            Thanks for your help Len

             

            Ted