HSE [Wait for Interrupt(WFI)] status understanding Currently, I am working on MCU clock initialization and waiting for the HSE to enter the WFI state (CLOCK_IP_WFI_EXECUTED == 0x80000000U) before proceeding with the clock configuration. The current implementation is shown below. However, my concern is that if the HSE never transitions to the WFI state, the ECU will remain stuck in the waiting loop indefinitely. Could you please suggest a suitable safeguard or timeout mechanism to handle this scenario safely? do { WfiStatus = (IP_MC_ME->PRTN0_CORE2_STAT & MC_ME_PRTN0_CORE2_STAT_WFI_MASK); } while (CLOCK_IP_WFI_EXECUTED != WfiStatus); Re: HSE [Wait for Interrupt(WFI)] status understanding Hi @ManuSharma1
The worst case is HSE firmware installation, update, or recovery, which can take approximately 1 second as mentioned in HSE-B firmware reference manual. Therefore, I would recommend a timeout of approximately 1.3 seconds to provide some margin and avoid an infinite wait if the expected WFI state is not reached.
Regards,
Lukas Re: HSE [Wait for Interrupt(WFI)] status understanding Dear @lukaszadrapa Thanks for the details. As suggested, I plan to use a timer-based timeout of approximately 1.3 seconds while waiting for the HSE to enter the WFI state. If the WFI status is not achieved within this timeout period, I intend to perform a fail-safe action. For the fail-safe action, I am considering performing an MCU reset, since the HSE would not be in a proper state to handle further requests. Before proceeding, I would appreciate your guidance on the following points: Is performing an MCU reset the correct approach for handling an HSE WFI timeout condition? If a reset is recommended, which reset type should be used: Functional Reset (FES), or Destructive Reset (DES)? In the S32K312 architecture, the HSE operates as a separate engine responsible for security-related functions. If an MCU reset is issued, will the HSE engine also be reset, or will it continue running independently? Your inputs will help ensure the timeout handling mechanism is implemented correctly and robustly. Thanks & Regards, Manu Sharma Re: HSE [Wait for Interrupt(WFI)] status understanding Hi @ManuSharma1
Generally, first step is to check HSE GPR at 0x4039_C028 if bit 0 is set. If bit 0 is ‘0’ after reset, HSE firmware is not present at all, it is erased completely due to some fatal error.
If the bit 0 in HSE GPR is ‘1’ (HSE FW present) but HSE_STATUS_INIT_OK remains ‘0’ after reset, it means that it’s necessary to start the handshake procedure. See “14.6.7 HSE Firmware Handshake” in HSE FW RM for details. As described in that section, you should trigger several functional resets.
External reset cannot be used because it triggers destructive reset. An option is to trigger functional reset by software. You can take a look at this post:
https://community.nxp.com/t5/S32K/S32K344-How-to-manually-trigger-one-Function-Reset/m-p/1506101/highlight/true#M17079
To sum it up:
After reset, check the bit 0 in HSE GPR register at 0x4039_C028. If it is 0, the firmware was already erased and you can try to install it again. If it is 1, go to next step.
Wait until bit HSE_STATUS_INIT_OK in FSR register is set. If it is set, HSE firmware is up and running. If it is not set in about 1s after reset (use timeout about 1.3s or more), trigger functional reset.
Repeat this procedure until the firmware is either recovered or erased. If it is erased, it’s necessary to install the firmware again.
Also notice that if you use AB_SWAP version and if the firmware is erased by SBAF due to some fatal error, the only option to install the firmware again is “installation via MU interface” method. Installation via IVT or installation via default location methods do not work in this case.
For more details, see section “10 Error and Warning Management” in HSE Firmware reference manual.
Regards,
Lukas
View full article