S32K116 Watchdog 16-bit

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K116 Watchdog 16-bit

620 Views
rjmalmeida0
Contributor II

Hello,

I am trying to use the 16-bit write to refresh the Watchdog but the program keeps crashing when it reaches the second value. I configure the watchdog for CMD32 = 0 and use the same function as the SDK (Wdg_Trigger) to try and refresh the watchdog. Below is the source code that refreshes the watchdog. One thing I've noticed is that the SDK's Wdg_Config driver forces the watchdog for 32 bit writes. This option is not changeable on processor expert. Any particular reason for it?

Thanks in advance,

Rui

/* @brief The first 16-bit value used for unlocking the WDOG. */
#define WDOG_UNLOCK16_FIRST_VALUE               (0xC520U)
/* @brief The second 16-bit value used for unlocking the WDOG. */
#define WDOG_UNLOCK16_SECOND_VALUE              (0xD928U)
/* @brief The first 16-bit value used for resetting the WDOG counter. */
#define WDOG_REFRESH16_FIRST_VALUE              (0xA602U)
/* @brief The second 16-bit value used for resetting the WDOG counter. */
#define WDOG_REFRESH16_SECOND_VALUE             (0xB480U)


/** Function to kick the watchdog
 * 
*/
void Wdg_Refresh(void)
{
 /* Disable interrupts */
 DISABLE_INTERRUPTS();
 /* Check if watch dog is 32 bit or 16 bit writes */ 
 if((WDOG->CS & WDOG_CS_CMD32EN_MASK) != 0U)
 {
 /* Write to CNT to refresh the watchdog (32 bit) */
 WDOG->CNT = WATCHDOG_REFRESH32_VALUE;
 }
 else
 {
 /* Write to CNT twice (16 bit) */
 WDOG->CNT = WDOG_REFRESH16_FIRST_VALUE;
 (void)WDOG->CNT;
 WDOG->CNT = WDOG_REFRESH16_SECOND_VALUE;
 }
 /* Enable interrupts */
 ENABLE_INTERRUPTS();
}
Labels (1)
Tags (2)
2 Replies

166 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Rui,

I have just tested it and it works without the read-after-write operation 

(void)WDOG->CNT;

which is not required anyway since the two writes are already serialized (both writes to the same register).

There are more features that are not implemented in the SDK yet.

Regards,

Daniel

166 Views
rjmalmeida0
Contributor II

Hello Daniel,
Thank you for the response, I will try it.

Regards,
Rui

0 Kudos